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


Python Figure.colorbar方法代码示例

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


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

示例1: check_and_plot

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
    def check_and_plot(self, A_nn, A0_nn, digits, keywords=''):
        # Construct fingerprint of input matrices for comparison
        fingerprint = np.array([md5_array(A_nn, numeric=True),
                                md5_array(A0_nn, numeric=True)])

        # Compare fingerprints across all processors
        fingerprints = np.empty((world.size, 2), np.int64)
        world.all_gather(fingerprint, fingerprints)
        if fingerprints.ptp(0).any():
            raise RuntimeError('Distributed matrices are not identical!')

        # If assertion fails, catch temporarily while plotting, then re-raise
        try:
            self.assertAlmostEqual(np.abs(A_nn-A0_nn).max(), 0, digits)
        except AssertionError:
            if world.rank == 0 and mpl is not None:
                from matplotlib.figure import Figure
                fig = Figure()
                ax = fig.add_axes([0.0, 0.1, 1.0, 0.83])
                ax.set_title(self.__class__.__name__)
                im = ax.imshow(np.abs(A_nn-A0_nn), interpolation='nearest')
                fig.colorbar(im)
                fig.text(0.5, 0.05, 'Keywords: ' + keywords, \
                    horizontalalignment='center', verticalalignment='top')

                from matplotlib.backends.backend_agg import FigureCanvasAgg
                img = 'ut_hsops_%s_%s.png' % (self.__class__.__name__, \
                    '_'.join(keywords.split(',')))
                FigureCanvasAgg(fig).print_figure(img.lower(), dpi=90)
            raise
开发者ID:ryancoleman,项目名称:lotsofcoresbook2code,代码行数:32,代码来源:ut_hsops.py

示例2: basic2DImage

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
 def basic2DImage(self, dataset, variables, varsToIgnore):
     fig = Figure(dpi=100)
     ax = fig.add_subplot(111)
     indepVars = variables[0]
     depVars = variables[1]
     if varsToIgnore == [depVars[ii][0] for ii in range(0,len(depVars))]:
         return fig
     dataset = np.asarray(dataset)
     print dataset[0]
     xlabel = self.dataChest.getParameter("X Label", True)
     if xlabel is None:
         xlabel = indepVars[0][0]
     ylabel = self.dataChest.getParameter("Y Label", True) 
     if ylabel is None:
         # For data with more than one dep, recommend ylabel.
         ylabel = depVars[0][0]
     plotTitle = self.dataChest.getParameter("Plot Title", True)
     if plotTitle is None:
         plotTitle = self.dataChest.getDatasetName()
     ax.set_title(plotTitle)
     ax.set_xlabel(xlabel+" "+"("+indepVars[0][3]+")")
     ax.set_ylabel(ylabel+" "+"("+depVars[0][3]+")")
     # For multiple deps with different units this is ambiguous.
     imageType = self.dataChest.getParameter("Image Type", True)
     if imageType is None:
         # Add or "scatter"
         imageType = "Scatter"
         print "Scatter"
         for ii in range(0, len(depVars)):
             x = dataset[::,0]
             y = dataset[::,1]
             z = dataset[::,2]
             im = ax.tricontourf(x,y,z, 100, cmap=cm.gist_rainbow, antialiased=True)
             fig.colorbar(im, fraction = 0.15)
             break
     elif imageType == "Pixel":
         xGridRes = self.dataChest.getParameter("X Resolution", True)
         xIncrement = self.dataChest.getParameter("X Increment", True)
         yGridRes = self.dataChest.getParameter("Y Resolution", True)
         yIncrement = self.dataChest.getParameter("Y Increment", True)
         x = dataset[::,0].flatten()
         y = dataset[::,1].flatten()
         z = dataset[::,2].flatten()
         if len(x)>1:
             if x[0]==x[1]:
                 sweepType = "Y"
             else:
                 sweepType = "X"
             print "sweepType=", sweepType
             new = self.makeGrid(x, xGridRes, xIncrement, y, yGridRes, yIncrement, sweepType, z) #makeGrid(self, x, xGridRes, dX, y, yGridRes, dY, sweepType, z)
             X = new[0]
             Y = new[1]
             Z = new[2]
             im = ax.imshow(Z, extent=(X.min(), X.max(), Y.min(), Y.max()), interpolation='nearest', cmap=cm.gist_rainbow, origin='lower')
             fig.colorbar(im, fraction = 0.15)
         else:
             print "return jack shit"
     elif imageType == "Buffered":
         print "Buffered"
     return fig
开发者ID:McDermott-Group,项目名称:servers,代码行数:62,代码来源:grapher.py

示例3: confusion_matrix_

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
def confusion_matrix_(y_test,
                      y_pred,
                      target_names,
                      normalize=False,
                      title='Confusion matrix',
                      cmap=plt.cm.Blues):
    cm = confusion_matrix(y_test, y_pred)
    if normalize:
        cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
    np.set_printoptions(precision=2)
    fig = Figure()
    canvas = FigureCanvas(fig)
    ax = fig.add_subplot(111)
    im = ax.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)
    fig.colorbar(im)
    tick_marks = np.arange(len(target_names))
    ax.set_xticks(tick_marks)
    ax.set_xticklabels(target_names, rotation=45)
    ax.set_yticks(tick_marks)
    ax.set_yticklabels(target_names)
    fig.tight_layout()
    ax.set_title(title)
    ax.set_ylabel('True label')
    ax.set_xlabel('Predicted label')
    return fig
开发者ID:dssg,项目名称:cincinnati,代码行数:27,代码来源:plots.py

示例4: plot_correlation

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
def plot_correlation(hist, title="Hit correlation", xlabel=None, ylabel=None, filename=None):
    logging.info("Plotting correlations")
    fig = Figure()
    FigureCanvas(fig)
    ax = fig.add_subplot(1, 1, 1)
    cmap = cm.get_cmap('jet')
    extent = [hist[2][0] - 0.5, hist[2][-1] + 0.5, hist[1][-1] + 0.5, hist[1][0] - 0.5]
    ax.set_title(title)
    ax.set_xlabel(xlabel)
    ax.set_ylabel(ylabel)
    im = ax.imshow(hist[0], extent=extent, cmap=cmap, interpolation='nearest')
    ax.invert_yaxis()
    # add colorbar
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", size="5%", pad=0.05)
    z_max = np.max(hist[0])
    bounds = np.linspace(start=0, stop=z_max, num=255, endpoint=True)
    norm = colors.BoundaryNorm(bounds, cmap.N)
    fig.colorbar(im, boundaries=bounds, cmap=cmap, norm=norm, ticks=np.linspace(start=0, stop=z_max, num=9, endpoint=True), cax=cax)
    if not filename:
        fig.show()
    elif isinstance(filename, PdfPages):
        filename.savefig(fig)
    else:
        fig.savefig(filename)
开发者ID:liuhb08,项目名称:pyBAR,代码行数:27,代码来源:plotting.py

示例5: PlotFigure

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
class PlotFigure(Frame):

    def __init__(self):
        Frame.__init__(self, None, -1, "Test embedded wxFigure")

        self.fig = Figure((5,4), 75)
        self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        tw, th = self.toolbar.GetSizeTuple()
        fw, fh = self.canvas.GetSizeTuple()
        self.toolbar.SetSize(Size(fw, th))

        # Create a figure manager to manage things

        # Now put all into a sizer
        sizer = BoxSizer(VERTICAL)
        # This way of adding to sizer allows resizing
        sizer.Add(self.canvas, 1, LEFT|TOP|GROW)
        # Best to allow the toolbar to resize!
        sizer.Add(self.toolbar, 0, GROW)
        self.SetSizer(sizer)
        self.Fit()
        EVT_TIMER(self, TIMER_ID, self.onTimer)

    def init_plot_data(self):
        # jdh you can add a subplot directly from the fig rather than
        # the fig manager
        a = self.fig.add_axes([0.075,0.1,0.75,0.85])
        cax = self.fig.add_axes([0.85,0.1,0.075,0.85])
        self.x = npy.empty((120,120))
        self.x.flat = npy.arange(120.0)*2*npy.pi/120.0
        self.y = npy.empty((120,120))
        self.y.flat = npy.arange(120.0)*2*npy.pi/100.0
        self.y = npy.transpose(self.y)
        z = npy.sin(self.x) + npy.cos(self.y)
        self.im = a.imshow( z, cmap=cm.jet)#, interpolation='nearest')
        self.fig.colorbar(self.im,cax=cax,orientation='vertical')

    def GetToolBar(self):
        # You will need to override GetToolBar if you are using an
        # unmanaged toolbar in your frame
        return self.toolbar

    def onTimer(self, evt):
        self.x += npy.pi/15
        self.y += npy.pi/20
        z = npy.sin(self.x) + npy.cos(self.y)
        self.im.set_array(z)
        self.canvas.draw()
        #self.canvas.gui_repaint()  # jdh wxagg_draw calls this already

    def onEraseBackground(self, evt):
        # this is supposed to prevent redraw flicker on some X servers...
        pass
开发者ID:charlie1kimo,项目名称:Zygo,代码行数:60,代码来源:dynamic_image_wxagg2.py

示例6: plot_fig

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
def plot_fig(fld,dt,varname,filename) :
   from matplotlib.backends.backend_agg import FigureCanvasAgg
   from matplotlib.figure import Figure
   fig = Figure(figsize=(5,4), dpi=100)
   ax = fig.add_subplot(111)
   canvas = FigureCanvasAgg(fig)
   P=ax.pcolor(fld)
   fig.colorbar(P)
   ax.set_title("%s at %s"%(varname,str(dt)))
   canvas.print_figure(filename)
开发者ID:knutalnersc,项目名称:modeltools,代码行数:12,代码来源:hycom_atmfor.py

示例7: ControlMatplotlib

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
class ControlMatplotlib(ControlBase, QtGui.QWidget):

    def __init__(self, label = ""):
        QtGui.QWidget.__init__(self)
        ControlBase.__init__(self, label)

    def initForm(self):

        self._fig = Figure((5.0, 4.0), dpi=100)
        self.canvas = FigureCanvas(self._fig)
        self.canvas.setParent(self)
        self.mpl_toolbar = NavigationToolbar(self.canvas, self)
     
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.mpl_toolbar)
        self.setLayout(vbox)

    def on_draw(self):
        """ Redraws the figure
        """
        self.data =[1,2,3,4]
        
        x = range(len(self.data))

        #self._axes = self._fig.add_subplot(111)
        
        #self._axes.bar(left=x, height=self.data)
        #self.canvas.draw()

        self._axes = self._fig.add_subplot(111, projection='3d')
        self._axes.clear(); 
        pts = self._axes.scatter(x, x, x, c=x)
        self._fig.colorbar(pts)


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

    @property
    def axes(self): return self._axes
    @axes.setter
    def axes(self, value): self._axes = value

    @property
    def fig(self): return self._fig
    @fig.setter
    def fig(self, value): self._fig = value


    @property
    def form(self): return self
开发者ID:ColinBrosseau,项目名称:pyforms,代码行数:55,代码来源:ControlMatplotlib.py

示例8: plot_search_map

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
def plot_search_map(datamap, zlim, cvflim, I, direction, fname):
    fig = Figure()
    ax = fig.add_subplot(111)
    extent = cvflim[0], cvflim[1], zlim[0], zlim[1]
    im = ax.imshow(datamap, cmap=cm.jet, interpolation='nearest', extent=extent, origin='lower')
    fig.colorbar(im)
    ax.set_aspect('auto')
    ax.set_xlabel('Vacancy concentration multiplier')
    ax.set_ylabel('z* (Effective valence)')
    ax.set_title(str.format('Least Squares Error for I = {}, {} bias', I, direction))
    canvas = FigureCanvas(fig)
    canvas.print_figure(fname)
开发者ID:KJTsanaktsidis,项目名称:FYP,代码行数:14,代码来源:dmplots.py

示例9: plot_reflectivity

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
  def plot_reflectivity(self, data, fname, title='', highres=False, this_run=None):
    '''
    Generate a graph with a combined reflectivity plot for all spin-states.
    If this_run is given it's raw data is shown on the right side of the same graph, too.
    '''
    logging.info('Saving plot to "%s".'%fname)
    if highres:
      fig=Figure(figsize=(10.667, 8.), dpi=150, facecolor='#FFFFFF')
      fig.subplots_adjust(left=0.1, bottom=0.1, top=0.95, right=0.98)
    elif this_run:
      fig=Figure(figsize=(11., 8.), dpi=72, facecolor='#FFFFFF')
      fig.subplots_adjust(left=0.1, bottom=0.1, top=0.95, right=0.98)
      gs=GridSpec(2, 2, width_ratios=[3, 1])
    else:
      fig=Figure(figsize=(6., 4.), dpi=72, facecolor='#FFFFFF')
      fig.subplots_adjust(left=0.12, bottom=0.13, top=0.94, right=0.98)
    canvas=FigureCanvasAgg(fig)
    if this_run:
      ax=fig.add_subplot(gs[:, 0])
      xy_ax=fig.add_subplot(gs[0,1])
      tof_ax=fig.add_subplot(gs[1, 1])
      p1, p2=self.plot_raw(xy_ax, tof_ax, this_run)
      fig.colorbar(p1, ax=xy_ax, orientation='horizontal')
      fig.colorbar(p2, ax=tof_ax, orientation='horizontal')
    else:
      ax=fig.add_subplot(111)

    ymin=1e10
    ymax=1e-10
    xmin=0.1
    xmax=0.01
    for x, y, label in data:
      try:
        ymin=min(y[y>0].min(), ymin)
      except ValueError:
        # ignore plots with zero intensity
        continue
      else:
        xmin=min(x.min(), xmin)
        xmax=max(x.max(), xmax)
      ymax=max(y.max(), ymax)
      ax.semilogy(x, y, label=label)
    ax.set_xlim(xmin-xmin%0.005, xmax-xmax%0.005+0.005)
    ax.set_ylim(ymin*0.75, ymax*1.25)
    ax.legend()
    ax.set_title(title)
    ax.set_xlabel('Q [$\\AA^{-1}$]')
    ax.set_ylabel('R')
    try:
      canvas.print_png(fname)
    except IOError:
      logging.warn('Could not save plot:', exc_info=True)
开发者ID:aglavic,项目名称:quicknxs,代码行数:54,代码来源:auto_reflectivity.py

示例10: createSpectra

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
    def createSpectra(self, xHighlight=None, yHighlight=None, contour=False, index=0):
        """
        Creates a spectragram graph. This function is called from the
        Core class. The spectragram is a three dimensional plot that
        shows current vs cycle vs time.

        @param xHighlight: defaults to none
        @param yHighlight: defaults to none
        @param contour: defaults to false
        @return null
        """

        # haven't touched this yet. will likely add new field in gui to cycle through indexes of spectras

        self.plotInfoStr = self.dataset.getInfo()

        print("Plotting spectra at index:", index)
        f = Figure()
        a = f.add_subplot(111)

        x = np.array(list(self.dataset.getXUnits()))
        y = np.array(range(len(self.dataset.getYUnits())))

        print("---\nsize of x: %i\nsize of y: %i" % (len(x), len(y)))

        X, Y = np.meshgrid(x, y)
        Z = np.array(self.dataset.getPlane()).transpose()

        if self.dataset.logifyY:
            Z = Z + np.abs(Z.min())
            a.pcolormesh(X, Y, Z, norm=matplotlib.colors.LogNorm(vmin=Z.min(), vmax=Z.max()))
        else:
            a.pcolormesh(X, Y, Z)
        bar = matplotlib.cm.ScalarMappable()
        bar.set_array(Z)
        if contour:
            a.contour(X, Y, Z)
        f.colorbar(bar, ax=a, label="Current (Im)")
        f.suptitle(str(self.dataset))

        if xHighlight != None:
            a.axvline(x=xHighlight)
            print("Trying to put bar at " + str(xHighlight))

        if yHighlight != None:
            a.axhline(y=yHighlight)
            print("Trying to put hLine at " + str(yHighlight))

        a.axis([X.min(), X.max(), Y.min(), Y.max()])
        return f
开发者ID:tuckerowens,项目名称:eCLAM,代码行数:52,代码来源:Plotter.py

示例11: plot_scurves

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
def plot_scurves(occupancy_hist, scan_parameters, title='S-Curves', ylabel='Occupancy', max_occ=None, scan_parameter_name=None, min_x=None, max_x=None, x_scale=1.0, y_scale=1., filename=None):  # tornado plot
    occ_mask = np.all(occupancy_hist == 0, axis=2)
    if max_occ is None:
        max_occ = 2 * np.median(np.amax(occupancy_hist, axis=2))
        if np.allclose(max_occ, 0.0):
            max_occ = np.amax(occupancy_hist)
        if np.allclose(max_occ, 0.0):
            max_occ = 1
    if len(occupancy_hist.shape) < 3:
        raise ValueError('Found array with shape %s' % str(occupancy_hist.shape))

    n_pixel = occupancy_hist.shape[0] * occupancy_hist.shape[1]

    cmap = cm.get_cmap('jet', 200)
    for index, scan_parameter in enumerate(scan_parameters):
        compressed_data = np.ma.masked_array(occupancy_hist[:, :, index], mask=occ_mask, copy=True).compressed()
        heatmap, xedges, yedges = np.histogram2d(compressed_data, [scan_parameter] * compressed_data.shape[0], range=[[0, max_occ], [scan_parameters[0], scan_parameters[-1]]], bins=(max_occ + 1, len(scan_parameters)))
        if index == 0:
            hist = heatmap
        else:
            hist += heatmap
    fig = Figure()
    FigureCanvas(fig)
    ax = fig.add_subplot(111)
    fig.patch.set_facecolor('white')
    if len(scan_parameters) > 1:
        scan_parameter_dist = (np.amax(scan_parameters) - np.amin(scan_parameters)) / (len(scan_parameters) - 1)
    else:
        scan_parameter_dist = 0
    extent = [yedges[0] - scan_parameter_dist / 2, yedges[-1] * x_scale + scan_parameter_dist / 2, xedges[-1] * y_scale + 0.5, xedges[0] - 0.5]
    norm = colors.LogNorm()
    im = ax.imshow(hist, interpolation='nearest', aspect="auto", cmap=cmap, extent=extent, norm=norm)
    ax.invert_yaxis()
    if min_x is not None or max_x is not None:
        ax.set_xlim((min_x if min_x is not None else np.amin(scan_parameters), max_x if max_x is not None else np.amax(scan_parameters)))
    fig.colorbar(im)
    ax.set_title(title + ' for %d pixel(s)' % (n_pixel - np.count_nonzero(occ_mask)))
    if scan_parameter_name is None:
        ax.set_xlabel('Scan parameter')
    else:
        ax.set_xlabel(scan_parameter_name)
    ax.set_ylabel(ylabel)
    if not filename:
        fig.show()
    elif isinstance(filename, PdfPages):
        filename.savefig(fig)
    else:
        fig.savefig(filename)
开发者ID:liuhb08,项目名称:pyBAR,代码行数:50,代码来源:plotting.py

示例12: heatmap

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
  def heatmap(self):
    [dates,watts] = self.building.data
    clipMax = scipy.stats.scoreatpercentile(watts,per=95)/1000
    clipMin = scipy.stats.scoreatpercentile(watts,per=0)/1000
    #watts[watts > clipMax] = clipMax

    [datesA,wattsA] = self.building.dailyData

    (m,n) = wattsA.shape
    fig = Figure(figsize=(10,6),facecolor='white',edgecolor='none')
    ax = fig.add_subplot(111)
    
    #print 'shapes:',m,n
    #print cm.coolwarm
    p = ax.imshow(wattsA/1000, interpolation='nearest', aspect='auto', cmap=cm.coolwarm, extent=[0,n*20*2,0,m*2])
    p.cmap.set_over('grey')
    cbar = fig.colorbar(p,ax=ax,shrink=0.8)
    cbar.set_label('kW')
    p.set_clim(clipMin, clipMax)
    ax.set_xticks(range(0,n*40+1,n*40/24*2))
    ax.set_xticklabels(['%iam' % x for x in [12]+range(2,12,2)] + ['%ipm' % x for x in [12] + range(2,12,2)] + ['12am'])
    # rotate lables
    for l in ax.xaxis.get_majorticklabels(): l.set_rotation(70)
    ax.set_yticks(range(1,m*2+1,30*2))
    ax.format_ydata = mpld.DateFormatter('%m/%d')
    ax.set_yticklabels([x.strftime('%m/%d/%y') for x in datesA[-1:1:-30,0]])
    #fig.autofmt_ydate()
    ax.tick_params(axis='both', which='major', labelsize=8)
    ax.set_title('Heat map of %s data for %s' % ('electricity','uploaded data'))
    ax.set_xlabel('Hour of day')
    ax.set_ylabel('Date')
    ax.grid(True)
    fig.subplots_adjust(top=1.0, left=0.20)
    return fig
开发者ID:sborgeson,项目名称:building-data-analysis,代码行数:36,代码来源:analysis.py

示例13: plot_tdc_event

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
def plot_tdc_event(points, filename=None):
    fig = Figure()
    FigureCanvas(fig)
    ax = fig.add_subplot(111, projection='3d')
    xs = points[:, 0]
    ys = points[:, 1]
    zs = points[:, 2]
    cs = points[:, 3]

    p = ax.scatter(xs, ys, zs, c=cs, s=points[:, 3] ** (2) / 5., marker='o')

    ax.set_xlabel('x [250 um]')
    ax.set_ylabel('y [50 um]')
    ax.set_zlabel('t [25 ns]')
    ax.title('Track of one TPC event')
    ax.set_xlim(0, 80)
    ax.set_ylim(0, 336)

    c_bar = fig.colorbar(p)
    c_bar.set_label('charge [TOT]')

    if not filename:
        fig.show()
    elif isinstance(filename, PdfPages):
        filename.savefig(fig)
    elif filename:
        fig.savefig(filename)
    return fig
开发者ID:liuhb08,项目名称:pyBAR,代码行数:30,代码来源:plotting.py

示例14: plot_cluster_tot_size

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
def plot_cluster_tot_size(hist, median=False, z_max=None, filename=None):
    H = hist[0:50, 0:20]
    if z_max is None:
        z_max = np.ma.max(H)
    if z_max < 1 or H.all() is np.ma.masked:
        z_max = 1
    fig = Figure()
    FigureCanvas(fig)
    ax = fig.add_subplot(111)
    extent = [-0.5, 20.5, 49.5, -0.5]
    bounds = np.linspace(start=0, stop=z_max, num=255, endpoint=True)
    cmap = cm.get_cmap('jet')
    cmap.set_bad('w')
    norm = colors.BoundaryNorm(bounds, cmap.N)
    im = ax.imshow(H, aspect="auto", interpolation='nearest', cmap=cmap, norm=norm, extent=extent)  # for monitoring
    ax.set_title('Cluster size and cluster ToT (' + str(np.sum(H) / 2) + ' entries)')
    ax.set_xlabel('cluster size')
    ax.set_ylabel('cluster ToT')

    ax.invert_yaxis()
    divider = make_axes_locatable(ax)
    cax = divider.append_axes("right", size="5%", pad=0.1)
    cb = fig.colorbar(im, cax=cax, ticks=np.linspace(start=0, stop=z_max, num=9, endpoint=True))
    cb.set_label("#")
    fig.patch.set_facecolor('white')
    if not filename:
        fig.show()
    elif isinstance(filename, PdfPages):
        filename.savefig(fig)
    else:
        fig.savefig(filename)
开发者ID:liuhb08,项目名称:pyBAR,代码行数:33,代码来源:plotting.py

示例15: plot_raw_only

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import colorbar [as 别名]
 def plot_raw_only(self, fname, this_run):
   '''
   Generate a graph with only the raw data and no reflectivity plot.
   '''
   fig=Figure(figsize=(11., 5.), dpi=72, facecolor='#FFFFFF')
   fig.subplots_adjust(left=0.1, bottom=0.1, top=0.95, right=0.98)
   canvas=FigureCanvasAgg(fig)
   xy_ax=fig.add_subplot(121)
   tof_ax=fig.add_subplot(122)
   p1, p2=self.plot_raw(xy_ax, tof_ax, this_run)
   fig.colorbar(p1, ax=xy_ax, orientation='vertical')
   fig.colorbar(p2, ax=tof_ax, orientation='vertical')
   try:
     canvas.print_png(fname)
   except IOError:
     logging.warn('Could not save raw plot:', exc_info=True)
开发者ID:aglavic,项目名称:quicknxs,代码行数:18,代码来源:auto_reflectivity.py


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