当前位置: 首页>>代码示例>>Python>>正文


Python FigureCanvasQTAgg.print_figure方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.print_figure方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.print_figure方法的具体用法?Python FigureCanvasQTAgg.print_figure怎么用?Python FigureCanvasQTAgg.print_figure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg的用法示例。


在下文中一共展示了FigureCanvasQTAgg.print_figure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plot_LO_horiz_stripes

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
def plot_LO_horiz_stripes():
    '''
    This uses data that has been processed through pik1 but w/ the hanning filter
    disabled s.t. the stripes are more readily apparent.
    '''
    fig = Figure((10, 4))
    canvas = FigureCanvas(fig)
    ax = fig.add_axes([0, 0, 1, 1])
    ax.axis('off')
    plot_radar(ax, 'TOT_stacked_nofilter', 3200, None, [135000, 230000])
    xlim = ax.get_xlim()
    ylim = ax.get_ylim()
    TOT_bounds, VCD_bounds, THW_bounds = find_quiet_regions()
    ax.vlines(TOT_bounds[0:2], 0, 3200, colors='red', linewidth=3, linestyles='dashed')    
    plot_bounding_box(ax, TOT_bounds, '', linewidth=4)
    ax.set_xlim(xlim)
    ax.set_ylim(ylim)

    canvas.print_figure('../FinalReport/figures/TOT_LO_stripes_d.jpg')

    zoom_bounds = [5000, 9000, 3000, 3200]
    zoom_fig = Figure((2.5, 9))
    zoom_canvas = FigureCanvas(zoom_fig)
    zoom_ax = zoom_fig.add_axes([0, 0, 1, 1])
    zoom_ax.axis('off')
    plot_radar(zoom_ax, 'TOT_stacked_nofilter', 3200, zoom_bounds, [135000, 230000])
    zoom_canvas.print_figure('../FinalReport/figures/TOT_LO_stripes_zoom.jpg')
开发者ID:lindzey,项目名称:EE_project,代码行数:29,代码来源:generate_images.py

示例2: GEMPlotterDialog

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
class GEMPlotterDialog(QtGui.QDialog):
    def __init__(self):
        QtGui.QDialog.__init__(self)
        # Set up the user interface from Designer.
        self.ui = Ui_GEMPlotter()
        self.ui.setupUi(self)
        self.modelfile = None
        self.ff = {}  # fragility functions dictionary
        self.fig = Figure()
        self.axes = self.fig.add_subplot(111)
        self.axes.grid(True)
        self.canvas = FigureCanvasQTAgg(self.fig)
        self.canvas.setParent(self)
        self.ui.plotLayout.addWidget(self.canvas)

    @QtCore.pyqtSlot()
    def on_cancelButton_clicked(self):
        self.close()

    @QtCore.pyqtSlot()
    def on_saveButton_clicked(self):
        choices = 'PNG (*.png)|*.png'
        path = unicode(QtGui.QFileDialog.getSaveFileName(
            self, 'Save plot', '', choices))
        self.canvas.print_figure(path)

    @QtCore.pyqtSlot(int)
    def plot_ff(self, taxonomy_idx):
        if taxonomy_idx <= 0:
            return
        self.axes.clear()
        taxonomy = str(self.ui.taxonomyCombo.itemText(taxonomy_idx))
        iml, ys = self.ff[taxonomy]
        for state, y in zip(self.states, ys):
            self.axes.plot(iml['imls'], y, label=state)
        self.axes.legend(loc='upper left')
        self.canvas.draw()
        self.ui.saveButton.setEnabled(True)

    @QtCore.pyqtSlot()
    def on_chooseButton_clicked(self):
        self.modelfile = unicode(QtGui.QFileDialog.getOpenFileName(
            self, 'Select Fragility Model file',
            QtCore.QDir.homePath(),
            'Model files (*.xml)'))
        # TODO: what to do if modelfile is empty?
        # what to do if the file is incorrect?
        self._fillCombo()
        self.ui.taxonomyCombo.currentIndexChanged.connect(self.plot_ff)

    def _fillCombo(self):
        p = iter(FragilityModelParser(self.modelfile))
        kind, self.states = next(p)
        self.ff = dict((taxonomy, (iml, y))
                       for taxonomy, iml, y, no_damage_limit in p)
        self.ui.taxonomyCombo.clear()
        self.ui.taxonomyCombo.addItems(['Taxonomy'] + self.ff.keys())
        self.ui.taxonomyCombo.setEnabled(True)
开发者ID:gem,项目名称:oq-eqcatalogue-tool,代码行数:60,代码来源:gemplotterdialog.py

示例3: write_eps

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
def write_eps(fig, outfile, dpi=72):
    """
    Write a eps of the given figure, indendent of the pyplot backend.
    However, if the figure was created from pyplot, an existing pyplot backend
    will be permanently changed and may be dysfunctional.
    """
    from matplotlib.backends.backend_ps import FigureCanvasPS as FigureCanvas

    canvas = FigureCanvas(fig)
    canvas.print_figure(outfile, dpi=dpi)
开发者ID:goerz,项目名称:mgplottools,代码行数:12,代码来源:mpl.py

示例4: plot_data_products

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
def plot_data_products():

    # Define all bounds first s.t. we can draw the context boxes on the 
    # dechirped image.

    # The raw bounds are for the full image
    raw_min_sample = 150
    raw_max_sample = 2300
    raw_bounds = [0, 9075, raw_min_sample, raw_max_sample]

    # The filtering needs to zoom in on the surface
    filter_bounds = [1700, 5900, 425, 650]

    # For the SNR improvements of incoherent stacking, look at the layers that just pop out.
    layer_bounds = [7400, 8580, 200, 1750]
    # For filtered, clim = [110000, 195000] and for stacked, clim=[140000, 225000]

    # Zooming in on the crevasses shows speckle nicely
    incoherent_bounds = [2880, 4900, 850, 1700]
    #The clim for this is best is the coherent is [150000, 234000] and incoherent is [160000, 234000]

    # Appropriate color limits depend on the processing used
    raw_clim = [25000, 90000]
    dechirped_clim = [115000, 200000]
    filtered_clim = [115000, 200000]

    # First, generate the raw figure that requires raw data + dechirped data
    # over the full transect.
    raw_shape = (50, 17)
    #raw_shape = (10, 17./5) # This is ugly ... 
    
    # fig_raw = Figure(raw_shape, dpi=150)
    # canvas_raw = FigureCanvas(fig_raw)
    # ax_raw = fig_raw.add_axes([0, 0, 1, 1])
    # ax_raw.axis('off')
    # plot_radar(ax_raw, 'TOT_raw', 3200, raw_bounds, raw_clim)
    # canvas_raw.print_figure('../FinalReport/figures/TOT_raw_full.jpg')


    multiple_bounds = [3050, 5325, 325, 2675]
    fig_multiples = Figure(raw_shape, dpi=150)
    canvas_multiples = FigureCanvas(fig_multiples)
    ax_multiples = fig_multiples.add_axes([0, 0, 1, 1])
    ax_multiples.axis('off')
    plot_radar(ax_multiples, 'TOT_no_blanking', 3200, multiple_bounds, clim=[140000, 230000])
    ax_multiples.text(3950, 900, 'surface multiple', color='red', fontsize=70,
                      horizontalalignment='left', verticalalignment='bottom')
    ax_multiples.text(3950, 2380, 'basal multiple', color='red', fontsize=70,
            horizontalalignment='left', verticalalignment='top')
    canvas_multiples.print_figure('../FinalReport/figures/TOT_multiples.jpg')
开发者ID:lindzey,项目名称:EE_project,代码行数:52,代码来源:generate_images.py

示例5: plot_before_after

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
def plot_before_after():
    
    shape = (36, 27)
    fig_old = Figure(shape, dpi=150)
    canvas_old = FigureCanvas(fig_old)
    ax_old = fig_old.add_axes([0, 0, 1, 1])
    ax_old.axis('off')
    old_filename = WAIS + '/targ/xtra/ICP3/CMP/pik1.RADnh3/TOT/JKB2d/X16a/MagLoResInco2'
    plot_radar(ax_old, old_filename, 3200, clim=[103000, 200000])
    canvas_old.print_figure('../FinalReport/figures/TOT_X16a_old.jpg')

    fig_new = Figure(shape, dpi=150)
    canvas_new = FigureCanvas(fig_new)
    ax_new = fig_new.add_axes([0, 0, 1, 1])
    ax_new.axis('off')
    plot_radar(ax_new, 'TOT_LO', 3200, clim=[136000, 233000])
    canvas_new.print_figure('../FinalReport/figures/TOT_X16a_new.jpg')
开发者ID:lindzey,项目名称:EE_project,代码行数:19,代码来源:generate_images.py

示例6: plot_all_utig_data

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
def plot_all_utig_data():
    '''
    Plots all UTIG transects on a simple basemap, with transects
    color-coded by season. 
    '''
    fig = Figure((24, 20))
    canvas = FigureCanvas(fig)
    ax = fig.add_axes([0,0,1,1])
    bgs = deva.basemapUtilities.make_background_dict(fig, ax)
    bg = bgs['modis_simple']
    bg.set_background()
    gls = deva.devaUtilities.make_grounding_line_dict()
    deva.devaUtilities.set_grounding_line(ax, gls, 'modis')

    ax.axis('equal')
    ax.set_xlim([-3000000, 3000000])
    ax.set_ylim([-2500000, 2500000])

    ax.tick_params(which='both', bottom=False, top=False, left=False, right=False)
    for side in ['bottom', 'top', 'left', 'right']:
        ax.spines[side].set_visible(False)

    transects = deva.devaUtilities.load_transects(antarctic=True)
    season_lookup = deva.utilities.SeasonLookup()
    for pst, data in transects.iteritems():
        season,_ = season_lookup.get_season(pst)
        if season is None:
            print "No season found for %s" % (pst)
            continue
        elif season in ['ASE1', '2001', 'ICP1', 'ICP2', 'ICP3', 'ICP4', 'ICP5']:
            color = 'k'
            zorder = 3
        elif season in ['ICP6']:
            color = 'darkgrey'
            zorder = 2
        else:
            color = 'lightgrey'
            zorder = 1
        ax.plot(data[:,1], data[:,2], color=color, linewidth=1.0, zorder=zorder)
    
    canvas.print_figure('../FinalReport/figures/all_data.png')
开发者ID:lindzey,项目名称:EE_project,代码行数:43,代码来源:generate_images.py

示例7: plot_quiet_regions

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
def plot_quiet_regions():
    # Plot the region that the noise was calculated from...
    # For TOT...
    TOT_bounds, VCD_bounds, THW_bounds = find_quiet_regions()

    # TOT/JKB2d/X16a gives: 
    # mag = 32809.224658469, phs = -0.90421798501485484
    # VCD/JKB2g/DVD01a gives:
    # mag = 15720.217174332585, phs = -0.98350090576267946
    # THW/SJB2/DRP02a gives:
    # 26158.900202734963, phs = 1.6808311318828895
    
    TOT_fig = Figure((10, 8))
    TOT_canvas = FigureCanvas(TOT_fig)
    TOT_ax = TOT_fig.add_axes([0, 0, 1, 1])
    TOT_ax.axis('off')
    plot_radar(TOT_ax, 'TOT_LO', 3200, None, [135000, 234000])
    xlim = TOT_ax.get_xlim()
    ylim = TOT_ax.get_ylim()
    TOT_ax.vlines(TOT_bounds[0:2], 0, 3200, colors='red', linewidth=3, linestyles='dashed')
    plot_bounding_box(TOT_ax, TOT_bounds, '', linewidth=4)
    TOT_ax.set_xlim(xlim)
    TOT_ax.set_ylim(ylim)
    TOT_canvas.print_figure('../FinalReport/figures/TOT_quiet_region.jpg')

    VCD_fig = Figure((10, 8))
    VCD_canvas = FigureCanvas(VCD_fig)
    VCD_ax = VCD_fig.add_axes([0, 0, 1, 1])
    VCD_ax.axis('off')
    plot_radar(VCD_ax, 'VCD_LO', 3200, None, [135000, 234000])
    xlim = VCD_ax.get_xlim()
    ylim = VCD_ax.get_ylim()
    VCD_ax.vlines(VCD_bounds[0:2], 0, 3200, colors='red', linewidth=3, linestyles='dashed')
    plot_bounding_box(VCD_ax, VCD_bounds, '', linewidth=4)
    VCD_ax.set_xlim(xlim)
    VCD_ax.set_ylim(ylim)
    VCD_canvas.print_figure('../FinalReport/figures/VCD_quiet_region.jpg')

    THW_fig = Figure((10, 8))
    THW_canvas = FigureCanvas(THW_fig)
    THW_ax = THW_fig.add_axes([0, 0, 1, 1])
    THW_ax.axis('off')
    plot_radar(THW_ax, 'THW_LO', 3200, None, [135000, 234000])
    xlim = THW_ax.get_xlim()
    ylim = THW_ax.get_ylim()
    THW_ax.vlines(THW_bounds[0:2], 0, 3200, colors='red', linewidth=3, linestyles='dashed')
    plot_bounding_box(THW_ax, THW_bounds, '', linewidth=4)
    THW_ax.set_xlim(xlim)
    THW_ax.set_ylim(ylim)
    THW_canvas.print_figure('../FinalReport/figures/THW_quiet_region.jpg')
开发者ID:lindzey,项目名称:EE_project,代码行数:52,代码来源:generate_images.py

示例8: plot_DC

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]
def plot_DC():    

    shape = (36, 18)

    TOT_bounds = [6000, 9075, 200, 800]
    
    fig_TOT_ch1 = Figure(shape, dpi=150)
    canvas_TOT_ch1 = FigureCanvas(fig_TOT_ch1)
    ax_TOT_ch1 = fig_TOT_ch1.add_axes([0, 0, 1, 1])
    ax_TOT_ch1.axis('off')
    old_filename = WAIS + '/targ/xtra/ICP3/CMP/pik1.RADnh3/TOT/JKB2d/X16a/MagLoResInco1'
    plot_radar(ax_TOT_ch1, old_filename, 3200, bounds=TOT_bounds, clim=[80000, 180000])
    canvas_TOT_ch1.print_figure('../FinalReport/figures/TOT_ch1_DC.jpg')

    fig_TOT_ch2 = Figure(shape, dpi=150)
    canvas_TOT_ch2 = FigureCanvas(fig_TOT_ch2)
    ax_TOT_ch2 = fig_TOT_ch2.add_axes([0, 0, 1, 1])
    ax_TOT_ch2.axis('off')
    plot_radar(ax_TOT_ch2, 'TOT_no_blanking', 3200, bounds=TOT_bounds, clim=[130000, 230000])
    canvas_TOT_ch2.print_figure('../FinalReport/figures/TOT_ch2_DC.jpg')

    VCD_bounds = [9600, 10470, 200, 800]
    
    fig_VCD_ch1 = Figure(shape, dpi=150)
    canvas_VCD_ch1 = FigureCanvas(fig_VCD_ch1)
    ax_VCD_ch1 = fig_VCD_ch1.add_axes([0, 0, 1, 1])
    ax_VCD_ch1.axis('off')
    old_filename = WAIS + '/targ/xtra/ICP4/CMP/pik1.RADnh3/VCD/JKB2g/DVD01a/MagLoResInco1'
    plot_radar(ax_VCD_ch1, old_filename, 3200, bounds=VCD_bounds, clim=[80000, 180000])
    canvas_VCD_ch1.print_figure('../FinalReport/figures/VCD_ch1_DC.jpg')

    fig_VCD_ch2 = Figure(shape, dpi=150)
    canvas_VCD_ch2 = FigureCanvas(fig_VCD_ch2)
    ax_VCD_ch2 = fig_VCD_ch2.add_axes([0, 0, 1, 1])
    ax_VCD_ch2.axis('off')
    plot_radar(ax_VCD_ch2, 'VCD_no_blanking', 3200, bounds=VCD_bounds, clim=[140000, 230000])
    canvas_VCD_ch2.print_figure('../FinalReport/figures/VCD_ch2_DC.jpg')    
开发者ID:lindzey,项目名称:EE_project,代码行数:39,代码来源:generate_images.py

示例9: Browse

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
            self.CMAP = 'jet'
        elif self.field == 'spectrum_width':
            self.vminmax = (SW_LIMS[0], SW_LIMS[1])
            self.CMAP = 'gist_ncar'
        elif self.field == 'specific_differential_phase':
            self.vminmax = (PHIDP_LIMS[0], PHIDP_LIMS[1]) 
            self.CMAP = 'RdBu_r'
        elif self.field == 'total_power':
            self.vminmax = (TP_LIMS[0], TP_LIMS[1])
            self.CMAP = 'jet'
           
        limit_strs = ('vmin', 'vmax', 'xmin', 'xmax', 'ymin', 'ymax')
        self.limits = {}
        
        # Now pull the default values
        self.limits['vmin'] = self.vminmax[0]
        self.limits['vmax'] = self.vminmax[1]
        self.limits['xmin'] = self.XRNG[0]
        self.limits['xmax'] = self.XRNG[1]
        self.limits['ymin'] = self.YRNG[0]
        self.limits['ymax'] = self.YRNG[1]
        
# #    def _build_cmap_dict(self):
# #        self.cmap_dict = {}
# #        self.cmap_dict['gist_ncar'] = matcm.get_cmap(name='gist_ncar')
# #        self.cmap_dict['RdBu_r'] = matcm.get_cmap(name='RdBu_r')
# #        self.cmap_dict['RdYlBu_r'] = matcm.get_cmap(name='RdYlBu_r
# #        self.cmap_dict['cool'] = matcm.get_cmap(name='cool
# #        self.cmap_dict['YlOrBr'] = matcm.get_cmap(name='YlOrBr
# #        self.cmap_dict['jet'] = matcm.get_cmap(name='jet
# #        self.cmap_dict['
# #        self.cmap_dict['
        
    def _check_default_field(self):
        '''Hack to perform a check on reflectivity to make it work with 
        a larger number of files
        This should only occur upon start up with a new file'''
        if self.field == 'reflectivity':
            if self.field in self.fieldnames:
                pass
            elif 'CZ' in self.fieldnames:
                self.field = 'CZ'
            elif 'DZ' in self.fieldnames:
                self.field = 'DZ'
            elif 'dbz' in self.fieldnames:
                self.field = 'dbz'
            elif 'DBZ' in self.fieldnames:
                self.field = 'DBZ'
            elif 'dBZ' in self.fieldnames:
                self.field = 'dBZ'
            elif 'Z' in self.fieldnames:
                self.field = 'Z'
            elif 'DBZ_S'in self.fieldnames:
                self.field = 'DBZ_S'
            elif 'reflectivity_horizontal'in self.fieldnames:
                self.field = 'reflectivity_horizontal'

                
    def _check_file_type(self):
        '''Check file to see if the file is airborne or rhi'''
        if self.radar.scan_type != 'rhi':
            pass
        else:
            try:
                (self.radar.metadata['platform_type'] == 'aircraft_tail') or \
                (self.radar.metadata['platform_type'] == 'aircraft')
                self.airborne = True
            except:
                self.rhi = True
            
            self._set_fig_ax_rhi()
 
    ########################
    # Warning methods #
    ########################
    def _ShowWarning(self, msg):
        '''Show a warning message'''
        flags = QtGui.QMessageBox.StandardButton()
        response = QtGui.QMessageBox.warning(self, "Warning!",
                                             msg, flags)
        if response == 0:
            print msg
        else:
            print "Warning Discarded!"
 
    ########################
    # Image save methods #
    ########################
    def _quick_savefile(self, PTYPE=IMAGE_EXT):
        '''Save the current display'''
        PNAME = self.display.generate_filename(self.field, self.tilt, ext=IMAGE_EXT)
        print "Creating "+ PNAME
        
    def _savefile(self, PTYPE=IMAGE_EXT):
        PBNAME = self.display.generate_filename(self.field, self.tilt, ext=IMAGE_EXT)
        file_choices = "PNG (*.png)|*.png"
        path = unicode(QtGui.QFileDialog.getSaveFileName(self, 'Save file', '', file_choices))
        if path:
            self.canvas.print_figure(path, dpi=DPI)
            self.statusBar().showMessage('Saved to %s' % path)
开发者ID:NortySpock,项目名称:artview,代码行数:104,代码来源:artview.py

示例10: Display

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
            self.CMAP = 'jet'
        elif field == 'spectrum_width':
            self.vminmax = (SW_LIMS[0], SW_LIMS[1])
            self.CMAP = 'gist_ncar'
        elif field == 'specific_differential_phase':
            self.vminmax = (PHIDP_LIMS[0], PHIDP_LIMS[1]) 
            self.CMAP = 'RdBu_r'
        elif field == 'total_power':
            self.vminmax = (TP_LIMS[0], TP_LIMS[1])
            self.CMAP = 'jet'
           
        limit_strs = ('vmin', 'vmax', 'xmin', 'xmax', 'ymin', 'ymax')
        self.limits = {}
        
        # Now pull the default values
        self.limits['vmin'] = self.vminmax[0]
        self.limits['vmax'] = self.vminmax[1]
        self.limits['xmin'] = self.XRNG[0]
        self.limits['xmax'] = self.XRNG[1]
        self.limits['ymin'] = self.YRNG[0]
        self.limits['ymax'] = self.YRNG[1]
        
# #    def _build_cmap_dict(self):
# #        self.cmap_dict = {}
# #        self.cmap_dict['gist_ncar'] = matcm.get_cmap(name='gist_ncar')
# #        self.cmap_dict['RdBu_r'] = matcm.get_cmap(name='RdBu_r')
# #        self.cmap_dict['RdYlBu_r'] = matcm.get_cmap(name='RdYlBu_r
# #        self.cmap_dict['cool'] = matcm.get_cmap(name='cool
# #        self.cmap_dict['YlOrBr'] = matcm.get_cmap(name='YlOrBr
# #        self.cmap_dict['jet'] = matcm.get_cmap(name='jet
# #        self.cmap_dict['
# #        self.cmap_dict['
        
    def _check_default_field(self):
        '''Hack to perform a check on reflectivity to make it work with 
        a larger number of files
        This should only occur upon start up with a new file'''
        if self.Vfield.value == 'reflectivity':
            if self.Vfield.value in self.fieldnames:
                pass
            elif 'CZ' in self.fieldnames:
                self.Vfield.change('CZ')
            elif 'DZ' in self.fieldnames:
                self.Vfield.change('DZ')
            elif 'dbz' in self.fieldnames:
                self.Vfield.change('dbz')
            elif 'DBZ' in self.fieldnames:
                self.Vfield.change('DBZ')
            elif 'dBZ' in self.fieldnames:
                self.Vfield.change('dBZ')
            elif 'Z' in self.fieldnames:
                self.Vfield.change('Z')
            elif 'DBZ_S'in self.fieldnames:
                self.Vfield.change('DBZ_S')
            elif 'reflectivity_horizontal'in self.fieldnames:
                self.Vfield.change('reflectivity_horizontal')

                
    def _check_file_type(self):
        '''Check file to see if the file is airborne or rhi'''
        if self.Vradar.value.scan_type != 'rhi':
            pass
        else:
            try:
                (self.Vradar.value.metadata['platform_type'] == 'aircraft_tail') or \
                (self.Vradar.value.metadata['platform_type'] == 'aircraft')
                self.airborne = True
            except:
                self.rhi = True
            
            self._set_fig_ax_rhi()
 
    ########################
    # Warning methods #
    ########################
    def _ShowWarning(self, msg):
        '''Show a warning message'''
        flags = QtGui.QMessageBox.StandardButton()
        response = QtGui.QMessageBox.warning(self, "Warning!",
                                             msg, flags)
        if response == 0:
            print msg
        else:
            print "Warning Discarded!"
 
    ########################
    # Image save methods #
    ########################
    def _quick_savefile(self, PTYPE=IMAGE_EXT):
        '''Save the current display'''
        PNAME = self.display.generate_filename(self.Vfield.value, self.Vtilt.value, ext=IMAGE_EXT)
        print "Creating "+ PNAME
        
    def _savefile(self, PTYPE=IMAGE_EXT):
        PBNAME = self.display.generate_filename(self.Vfield.value, self.Vtilt.value, ext=IMAGE_EXT)
        file_choices = "PNG (*.png)|*.png"
        path = unicode(QtGui.QFileDialog.getSaveFileName(self, 'Save file', '', file_choices))
        if path:
            self.canvas.print_figure(path, dpi=DPI)
            self.statusBar().showMessage('Saved to %s' % path)
开发者ID:NortySpock,项目名称:artview,代码行数:104,代码来源:plot.py

示例11: GridDisplay

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
                return ''
        else:
            return ''

    def _check_file_type(self):
        '''Check file to see if the file type.'''
        # self._update_fig_ax()
        return

    def change_plot_type(self, plot_type):
        '''Change plot type.'''
        # remove shared variables
        for key in ("VlevelZ", "VlevelY", "VlevelX"):
            if key in self.sharedVariables.keys():
                del self.sharedVariables[key]
        if plot_type == "gridZ":
            self.sharedVariables["VlevelZ"] = self.NewLevel
        elif plot_type == "gridY":
            self.sharedVariables["VlevelY"] = self.NewLevel
        elif plot_type == "gridX":
            self.sharedVariables["VlevelX"] = self.NewLevel
        else:
            import warnings
            warnings.warn('Invalid Plot type %s, reseting to gridZ' %
                          plot_type)
            self.sharedVariables["VlevelZ"] = self.NewLevel
            plot_type = "gridZ"
        self.plot_type = plot_type

    ########################
    # Image save methods #
    ########################

    def _quick_savefile(self, PTYPE=IMAGE_EXT):
        '''Save the current display via PyArt interface.'''
        imagename = self.display.generate_filename(
            self.Vfield.value, self.Vlevel.value, ext=IMAGE_EXT)
        self.canvas.print_figure(os.path.join(os.getcwd(), imagename),
                                 dpi=DPI)
        self.statusbar.showMessage('Saved to %s' % os.path.join(os.getcwd(),
                                                                imagename))

    def _savefile(self, PTYPE=IMAGE_EXT):
        '''Save the current display using PyQt dialog interface.'''
        imagename = self.display.generate_filename(
            self.Vfield.value, self.Vlevel.value, ext=IMAGE_EXT)
        file_choices = "PNG (*.png)|*.png"
        path = unicode(QtGui.QFileDialog.getSaveFileName(
            self, 'Save file', imagename, file_choices))
        if path:
            self.canvas.print_figure(path, dpi=DPI)
            self.statusbar.showMessage('Saved to %s' % path)

    ########################
    #      get methods     #
    ########################

    def getPlotAxis(self):
        ''' get :py:class:`matplotlib.axes.Axes` instance of main plot '''
        return self.ax

    def getStatusBar(self):
        ''' get :py:class:`PyQt4.QtGui.QStatusBar` instance'''
        return self.statusbar

    def getField(self):
        ''' get current field '''
        return self.Vfield.value

    def getUnits(self):
        ''' get current units '''
        return self.units

    ########################
    #      Properties      #
    ########################

    @property
    def Vlevel(self):
        '''Alias to VlevelZ, VlevelY or VlevelX depending on plot_type.'''
        if self.plot_type == "gridZ":
            return self.VlevelZ
        elif self.plot_type == "gridY":
            return self.VlevelY
        elif self.plot_type == "gridX":
            return self.VlevelX
        else:
            return None

    @property
    def levels(self):
        '''Values from the axes of grid, depending on plot_type.'''
        if self.plot_type == "gridZ":
            return self.Vgrid.value.axes['z_disp']['data'][:]
        elif self.plot_type == "gridY":
            return self.Vgrid.value.axes['y_disp']['data'][:]
        elif self.plot_type == "gridX":
            return self.Vgrid.value.axes['x_disp']['data'][:]
        else:
            return None
开发者ID:kirknorth,项目名称:artview,代码行数:104,代码来源:plot_grid.py

示例12: AppForm

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
        hbox03.addWidget(self.button_loadThresholds)
        gbox0.addLayout(hbox03)
        
        gbox1 = QVBoxLayout()
        gbox1.addWidget(label_DACfreqs)
        gbox1.addWidget(self.textedit_DACfreqs)

        gbox2 = QVBoxLayout()
        hbox20 = QHBoxLayout()
        hbox20.addWidget(self.textbox_channel)
        hbox20.addWidget(self.button_channelInc)
        gbox2.addLayout(hbox20)
        hbox21 = QHBoxLayout()
        hbox21.addWidget(self.button_snapshot)
        hbox21.addWidget(self.textbox_snapSteps)
        hbox21.addWidget(label_snapSteps)
        gbox2.addLayout(hbox21)
        hbox22 = QHBoxLayout()
        hbox22.addWidget(self.button_longsnapshot)
        hbox22.addWidget(self.textbox_longsnapSteps)
        hbox22.addWidget(label_longsnapSteps)
        gbox2.addLayout(hbox22)
        gbox2.addWidget(self.button_rmCustomThreshold)
        hbox23 = QHBoxLayout()
        hbox23.addWidget(self.textbox_seconds)
        hbox23.addWidget(self.button_readPulses)
        gbox2.addLayout(hbox23)

        gbox3 = QVBoxLayout()
        gbox3.addWidget(self.label_median)
        gbox3.addWidget(self.label_threshold)
        gbox3.addWidget(self.label_attenuation)
        gbox3.addWidget(self.label_frequency)

        hbox = QHBoxLayout()
        hbox.addLayout(gbox0)
        hbox.addLayout(gbox1)     
        hbox.addLayout(gbox2)
        hbox.addLayout(gbox3)
        
        vbox = QVBoxLayout()
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.mpl_toolbar)
        vbox.addLayout(hbox)
        
        self.main_frame.setLayout(vbox)
        self.setCentralWidget(self.main_frame)
  
    def create_status_bar(self):
        self.status_text = QLabel("Awaiting orders.")
        self.statusBar().addWidget(self.status_text, 1)
        
    def create_menu(self):        
        self.file_menu = self.menuBar().addMenu("&File")
        
        load_file_action = self.create_action("&Save plot",shortcut="Ctrl+S", slot=self.save_plot, tip="Save the plot")
        quit_action = self.create_action("&Quit", slot=self.close, shortcut="Ctrl+Q", tip="Close the application")
        
        self.add_actions(self.file_menu, (load_file_action, None, quit_action))
        
        self.help_menu = self.menuBar().addMenu("&Help")
        about_action = self.create_action("&About", shortcut='F1', slot=self.on_about, tip='About the demo')
        
        self.add_actions(self.help_menu, (about_action,))

    def add_actions(self, target, actions):
        for action in actions:
            if action is None:
                target.addSeparator()
            else:
                target.addAction(action)

    def create_action(  self, text, slot=None, shortcut=None, 
                        icon=None, tip=None, checkable=False, 
                        signal="triggered()"):
        action = QAction(text, self)
        if icon is not None:
            action.setIcon(QIcon(":/%s.png" % icon))
        if shortcut is not None:
            action.setShortcut(shortcut)
        if tip is not None:
            action.setToolTip(tip)
            action.setStatusTip(tip)
        if slot is not None:
            self.connect(action, SIGNAL(signal), slot)
        if checkable:
            action.setCheckable(True)
        return action

    def save_plot(self):
        file_choices = "PNG (*.png)|*.png"
        path = unicode(QFileDialog.getSaveFileName(self, 'Save file', '',file_choices))
        if path:
            self.canvas.print_figure(path, dpi=self.dpi)
            self.statusBar().showMessage('Saved to %s' % path, 2000)
    
    def on_about(self):
        msg = """ Message to user goes here.
        """
        QMessageBox.about(self, "MKID-ROACH software demo", msg.strip())
开发者ID:bmazin,项目名称:SDR,代码行数:104,代码来源:channelizerSnap.py

示例13: MplFigureCellWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
                
            # self.figure.set_size_inches(8.0,6.0)
            self.canvas = FigureCanvasQTAgg(self.figure)
            self.mplToolbar = MplNavigationToolbar(self.canvas, None)
            self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                      QtGui.QSizePolicy.Expanding)
            # self.figManager = FigureManagerBase(self.canvas, self.figure.number)
            self.layout().addWidget(self.canvas)

            # Update the new figure canvas
            # self.canvas.draw()
            # self.layout().addWidget(self.getFigManager().window)

        # Update the new figure canvas
        # self.getFigManager().canvas.draw()            

        # # Replace the old one with the new one
        # if newFigManager!=self.figManager:
            
        #     # Remove the old figure manager
        #     if self.figManager:
        #         self.figManager.window.hide()
        #         self.layout().removeWidget(self.figManager.window)

        #     # Add the new one in
        #     self.layout().addWidget(newFigManager.window)

        #     # Destroy the old one if possible
        #     if self.figManager:
                
        #         try:                    
        #             pylab.close(self.figManager.canvas.figure)
        #         # There is a bug in Matplotlib backend_qt4. It is a
        #         # wrong command for Qt4. Just ignore it and continue
        #         # to destroy the widget
        #         except:
        #             pass
                
        #         self.figManager.window.deleteLater()
        #         del self.figManager

        #     # Save back the manager
        #     self.figManager = newFigManager
        #     self.update()

    def keyPressEvent(self, event):
        print "KEY PRESS:",  event.key()
        self.canvas.keyPressEvent(event)

    def keyReleaseEvent(self, event):
        print "KEY RELEASE:", event.key()
        self.canvas.keyReleaseEvent(event)

    def deleteLater(self):
        """ deleteLater() -> None        
        Overriding PyQt deleteLater to free up resources
        
        """
        # Destroy the old one if possible
        if self.figure is not None:
            # self.getFigManager().window.deleteLater()
            print "pylab:", pylab
            print "self.figure:", self.figure
            pylab.close(self.figure)
            
        # if self.figManager:
            
        #     try:                    
        #         pylab.close(self.figManager.canvas.figure)
        #     # There is a bug in Matplotlib backend_qt4. It is a
        #     # wrong command for Qt4. Just ignore it and continue
        #     # to destroy the widget
        #     except:
        #         pass
            
        #     self.figManager.window.deleteLater()
        QCellWidget.deleteLater(self)

    def grabWindowPixmap(self):
        """ grabWindowPixmap() -> QPixmap
        Widget special grabbing function
        
        """
        # pylab.figure(self.figNumber)
        # figManager = pylab.get_current_fig_manager()
        return QtGui.QPixmap.grabWidget(self.canvas)

    def dumpToFile(self, filename):
        previous_size = tuple(self.figure.get_size_inches())
        self.figure.set_size_inches(8.0,6.0)
        self.canvas.print_figure(filename)
        self.figure.set_size_inches(previous_size[0],previous_size[1])
        self.canvas.draw()
        
    def saveToPDF(self, filename):
        previous_size = tuple(self.figure.get_size_inches())
        self.figure.set_size_inches(8.0,6.0)
        self.canvas.print_figure(filename)
        self.figure.set_size_inches(previous_size[0],previous_size[1])
        self.canvas.draw()
开发者ID:cjh1,项目名称:VisTrails,代码行数:104,代码来源:figure_cell.py

示例14: MainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
        self.comenzar.setText('Comenzar')
        self.pause.setText('Pausar')
        self.pause.setDisabled(True)

    def comenzarPrueba(self):
        self.data = []
        self.tiempoTrancurrido = 0
        self.draw_chart()
        if self.tiempoFijo.isChecked():
            self.contadorPrincipal.setInterval(
                self.tiempoPrueba.value() * 1000)
        else:
            self.contadorPrincipal.setInterval(525600000)  # Un año
        self.contadorActializa.start()
        self.contadorPrincipal.start()
        self.comenzar.setText('Detener')
        self.pause.setDisabled(False)

    def togglePrueba(self):
        """Metodo para comenzar y detener la prueba actual"""
        if self.comenzar.isChecked():
            self.comenzarPrueba()
        else:
            self.detenerPrueba()

    def cambiaPolitica(self):
        """Habilita la interfaz para manejo manual del tiempo"""
        if self.tiempoIlimitado.isChecked():
            self.tiempoPrueba.setDisabled(True)
        else:
            self.tiempoPrueba.setEnabled(True)

    def doGuardar(self):
        """Verifica la existencia de datos y los guarda en png, cvs y pdf"""
        if self.nombre.text() == '':
            mensaje = QMessageBox(self)
            mensaje.setText('Ingrese un nombre para la prueba')
            mensaje.setWindowTitle('Error al guardar')
            mensaje.setIcon(QMessageBox.Critical)
            mensaje.exec_()
        elif len(self.data) == 0:
            mensaje = QMessageBox(self)
            mensaje.setText('No hay datos para guardar')
            mensaje.setWindowTitle('Error al guardar')
            mensaje.setIcon(QMessageBox.Critical)
            mensaje.exec_()
        else:
            nombre = str(self.nombre.text().toUtf8())
            archivo = open(nombre + '.csv', 'w')
            archivo.write(str(self.data)[1:-1] + '\n')
            archivo.close()

            pdf = PdfPages(nombre + '.pdf')
            self.fig.savefig(pdf, format='pdf')
            pdf.close()

            self.canvas.print_figure(nombre + '.png', dpi=self.dpi)

            mensaje = QMessageBox(self)
            mensaje.setText('La prueba a sido guardada correctamente')
            mensaje.setWindowTitle('Guardado con exito')
            mensaje.setIcon(QMessageBox.Information)
            mensaje.exec_()

    def doPause(self):
        """Maneja las pausas de la aplicación"""
        if self.contadorActializa.isActive():
            self.contadorActializa.stop()
            self.contadorPrincipal.stop()
            self.pause.setText('Reanudar')
        else:
            self.contadorActializa.start()
            # Recalcula el tiempo restante de la prueba
            self.contadorPrincipal.setInterval(
                self.tiempoPrueba.value() * 1000 - self.tiempoTrancurrido)
            self.contadorPrincipal.start()
            self.pause.setText('Pausar')

    def refresh(self):
        """Agrega un dato al conjunto y regenera la gráfica"""
        self.tiempoTrancurrido += 1000 / self.lecturasXSegundo
        self.data.append(int(self.arduino.data))
        self.draw_chart()

    def draw_chart(self):
        """Regenera la grafica"""
        count = round(len(self.data) * 1.0 / self.lecturasXSegundo, 3)
        xmax = count if count > 3 else 3
        xmin = 0

        self.axes.set_xbound(lower=xmin, upper=xmax)
        self.axes.set_ybound(lower=0, upper=1023)

        self.line.set_xdata(np.arange(0, count, 1.0 / self.lecturasXSegundo))
        self.line.set_ydata(np.array(self.data))

        self.canvas.draw()

    def closeEvent(self, event):
        self.arduino.stop()
开发者ID:arksega,项目名称:Rheometro,代码行数:104,代码来源:Core.py

示例15: PlotDisplay

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import print_figure [as 别名]

#.........这里部分代码省略.........
        if self.title == '':
            title = None
        else:
            title = self.title

        colorbar_flag=False

        self.cmap = {'vmin': self.data.min(), 'vmax': self.data.max(),
                     'cmap': 'pyart_RefDiff'}

        if self.plot_type == "hist":
            self.plot = self.ax.hist(self.data, bins=25,
                range = (self.cmap['vmin'], self.cmap['vmax']),
                figure=self.fig)
            self.ax.set_ylabel("Counts")
            if self.xlabel:
                self.ax.set_xlabel(self.xlabel)

        elif self.plot_type == "hist2d":
            # Check that y data was provided
            if self.ydata:
                y = self.ydata
            # Create Plot
            self.plot = self.ax.hist2d(self.data, y,
                bins=[25, 20],
                range=[[self.cmap['vmin'], self.cmap['vmax']],
                       [y.min(), y.max()]],
                cmap=self.cm_name,
                figure=self.fig)
            colorbar_flag=True

        elif self.plot_type == "plot":
            # Check that y data was provided
            if self.ydata:
                y = self.ydata
            # Create Plot
            self.plot = self.ax.plot(self.data, y,
                figure=self.fig)

        # Set the axis labels if arguments passed
        if self.xlabel:
            self.ax.set_xlabel(self.xlabel)
        if self.ylabel:
            self.ax.set_ylabel(self.ylabel)

        # If limits exists, update the axes otherwise retrieve
        if self.limits:
            self._update_axes()
        else:
            self._get_axes_limits()

        # Set the title if passed
        if title is not None:
            self.ax.set_title(title)

        # If the colorbar flag is thrown, create it
        if colorbar_flag:
            # Clear the colorbar axes
            self.cax.cla()
            self.cax = self.fig.add_axes([0.2, 0.10, 0.7, 0.02])
            norm = mlabNormalize(vmin=self.cmap['vmin'],
                                 vmax=self.cmap['vmax'])
            self.cbar = mlabColorbarBase(self.cax, cmap=self.cm_name,
                                         norm=norm, orientation='horizontal')
            # colorbar - use specified units or default depending on
            # what has or has not been entered
            if self.units is None or self.units == '':
                self.units = ''
            self.cbar.set_label(self.units)

        self.canvas.draw()

    def _update_axes(self):
        '''Change the Plot Axes.'''
        self.ax.set_xlim(self.limits['xmin'], self.limits['xmax'])
        self.ax.set_ylim(self.limits['ymin'], self.limits['ymax'])
        self.ax.figure.canvas.draw()

    def _get_axes_limits(self):
        '''Get the axes limits'''
        xlim = self.ax.get_xlim()
        ylim = self.ax.get_ylim()
        self.limits = {}
        self.limits['xmin'] = xlim[0]
        self.limits['xmax'] = xlim[1]
        self.limits['ymin'] = ylim[0]
        self.limits['ymax'] = ylim[1]

    ########################
    # Image save methods #
    ########################

    def _savefile(self, PTYPE=IMAGE_EXT):
        '''Save the current display using PyQt dialog interface.'''
        file_choices = "PNG (*.png)|*.png"
        path = unicode(QtGui.QFileDialog.getSaveFileName(
            self, 'Save file', ' ', file_choices))
        if path:
            self.canvas.print_figure(path, dpi=DPI)
            self.statusbar.showMessage('Saved to %s' % path)
开发者ID:tjlang,项目名称:artview,代码行数:104,代码来源:plot_simple.py


注:本文中的matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.print_figure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。