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


Python Figure.add_subplot方法代码示例

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


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

示例1: MplCanvas

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
class MplCanvas(FigureCanvas):
	def __init__(self, nsubplots=1):
		self.dpi=100
			
		self.fig = Figure(dpi=self.dpi, tight_layout=True)
		if nsubplots==2:
			# self.fig, (self.ax, self.ax2) = plt.subplots(1,2, sharey=True)
			# self.fig.set_tight_layout(True)
			self.gs= gridspec.GridSpec(1, 2, width_ratios=[5, 1]) 
			self.gs.update(left=0.15, right=0.97, bottom=0.22, top=0.94, wspace=0.07)
			self.ax = self.fig.add_subplot(self.gs[0])
			self.ax2 = self.fig.add_subplot(self.gs[1], sharey=self.ax)
			self.ax.hold(False)
			self.ax2.hold(False)
		else:
			self.ax = self.fig.add_subplot(1,1,1)
			self.ax.hold(False)

		FigureCanvas.__init__(self, self.fig)

		FigureCanvas.setSizePolicy(self, 
				QSizePolicy.Expanding, 
				QSizePolicy.Expanding
			)

		FigureCanvas.updateGeometry(self)
开发者ID:abalijepalli,项目名称:mosaic,代码行数:28,代码来源:mplwidget.py

示例2: plot_frame_displacement

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
def plot_frame_displacement(realignment_parameters_file, mean_FD_distribution=None, figsize=(11.7,8.3)):

    FD_power = calc_frame_dispalcement(realignment_parameters_file)

    fig = Figure(figsize=figsize)
    FigureCanvas(fig)
    
    if mean_FD_distribution:
        grid = GridSpec(2, 4)
    else:
        grid = GridSpec(1, 4)
    
    ax = fig.add_subplot(grid[0,:-1])
    ax.plot(FD_power)
    ax.set_xlim((0, len(FD_power)))
    ax.set_ylabel("Frame Displacement [mm]")
    ax.set_xlabel("Frame number")
    ylim = ax.get_ylim()
    
    ax = fig.add_subplot(grid[0,-1])
    sns.distplot(FD_power, vertical=True, ax=ax)
    ax.set_ylim(ylim)
    
    if mean_FD_distribution:
        ax = fig.add_subplot(grid[1,:])
        sns.distplot(mean_FD_distribution, ax=ax)
        ax.set_xlabel("Mean Frame Dispalcement (over all subjects) [mm]")
        MeanFD = FD_power.mean()
        label = "MeanFD = %g"%MeanFD
        plot_vline(MeanFD, label, ax=ax)
        
    return fig
开发者ID:JanineBijsterbosch,项目名称:mriqc,代码行数:34,代码来源:motion.py

示例3: workDone

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
    def workDone(self, days=30):
        self.calcStats()

        for type in ["dayRepsNew", "dayRepsYoung", "dayRepsMature"]:
            self.addMissing(self.stats[type], -days, 0)

        fig = Figure(figsize=(self.width, self.height), dpi=self.dpi)
        graph = fig.add_subplot(111)

        args = sum((self.unzip(self.stats[type].items(), limit=days, reverseLimit=True) for type in ["dayRepsMature", "dayRepsYoung", "dayRepsNew"][::-1]), [])

        self.varGraph(graph, days, [reviewNewC, reviewYoungC, reviewMatureC], *args)

        cheat = fig.add_subplot(111)
        b1 = cheat.bar(-3, 0, color = reviewNewC)
        b2 = cheat.bar(-4, 0, color = reviewYoungC)
        b3 = cheat.bar(-5, 0, color = reviewMatureC)

        cheat.legend([b1, b2, b3], [
            "New",
            "Young",
            "Mature"], loc='upper left')

        graph.set_xlim(xmin=-days+1, xmax=1)
        graph.set_ylim(ymax=max(max(a for a in args[1::2])) + 10)
        graph.set_xlabel("Day (0 = today)")
        graph.set_ylabel("Cards Answered")

        return fig
开发者ID:ACEfanatic02,项目名称:anki,代码行数:31,代码来源:graphs.py

示例4: plot_haven

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
def plot_haven(infect_prob_free, infect_prob_safe, infect_duration,
               latent_period, kill_prob, time_to_shelter):
    """
    Plot Haven, return canvas
    """
    haven = Haven(
        infect_prob_free, infect_prob_safe, infect_duration,
        latent_period, kill_prob, time_to_shelter)
    figure = Figure()
    canvas = FigureCanvasAgg(figure)
    axes = figure.add_subplot(2, 1, 1)
    if haven is not False:
        axes.plot(haven[0], haven[1], 'g--', linewidth=3)
        axes.plot(haven[0], haven[2], '-.b', linewidth=3)
        axes.plot(haven[0], haven[3], ':m', linewidth=3)
        axes.plot(haven[0], haven[4], 'r-', linewidth=3)
        axes.set_xlabel("Time (days)")
        axes.set_ylabel("Percent of Population")
        axes.set_title("Zombie Epidemic with Safe Haven")
        axes.grid(True)
        axes.legend(
            ("Wandering", "Safe Survivors", "Latent", "Infected"), shadow=True,
            fancybox=True)
        axes = figure.add_subplot(2, 1, 2)
        axes.plot(haven[0], haven[5], 'k--', linewidth=3)
        axes.plot(haven[0], haven[6], '-.b', linewidth=3)
        axes.set_xlabel("Time (days)")
        axes.set_ylabel("Percent of Population")
        axes.grid(True)
        axes.legend(("Culled", "Dead"), shadow=True, fancybox=True)
    else:
        ab = error()
        axes.set_title("Sorry, there has been an error.")
        axes.add_artist(ab)
    return canvas
开发者ID:epimodels,项目名称:Zeke,代码行数:37,代码来源:views.py

示例5: startup_cost

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
def startup_cost():
    import datetime
    import StringIO
    import random
    import base64

    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    from matplotlib.figure import Figure
    from matplotlib.dates import DateFormatter

    fig=Figure(facecolor='#ffffff')
    ax=fig.add_subplot(211)
    ax2=fig.add_subplot(212, axisbg='y')
    x=[]
    y=[]
    now=datetime.datetime.now()
    delta=datetime.timedelta(days=1)
    for i in range(10):
        x.append(now)
        now+=delta
        y.append(random.randint(0, 1000))
    ax.plot_date(x, y, '-')
    ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
    ax2.plot_date(x, y, '-')
    ax2.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
    fig.autofmt_xdate()
    canvas=FigureCanvas(fig)
    png_output = StringIO.StringIO()
    canvas.print_png(png_output)
    image=make_response(png_output.getvalue())
    response.headers['Content-Type'] = 'image/png'
    return response
开发者ID:rlundquist3,项目名称:colony.farm,代码行数:34,代码来源:startup_cost_2.py

示例6: MatplotlibWidget

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

	def __init__(self, parent=None, width=5, height=4, dpi=100):

		super(MatplotlibWidget, self).__init__(Figure())

#		self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
		self.setParent(parent)
		self.figure = Figure(figsize=(width, height), dpi=dpi) 
		self.canvas = FigureCanvas(self.figure)

#		FigureCanvas.setSizePolicy(self,
#				QtGui.QSizePolicy.Expanding,
#				QtGui.QSizePolicy.Expanding)

		FigureCanvas.updateGeometry(self)
		self.axes = self.figure.add_subplot(111)
		self.setMinimumSize(self.size()*0.3)

		print("---------------------- done")




	def subplot(self,label='111'):
		self.axes=self.figure.add_subplot(label)

	def plot(self,*args,**args2):
		self.axes.plot(*args,**args2)
		self.draw()

	def clf(self):
		self.figure.clf()
开发者ID:microelly2,项目名称:reconstruction,代码行数:35,代码来源:mpl.py

示例7: Canvas

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
class Canvas(FigureCanvas):
    def __init__(self, parent=None, width=5, height=4, dpi=100, nD = 2):
        # plt.xkcd()
        self.fig = Figure(figsize=(width, height), dpi=dpi)
        FigureCanvas.__init__(self, self.fig)
        self.dim = nD
        if self.dim is 2:
            self.axes = self.fig.add_subplot(1, 1, 1)
            pass
        else:
            self.axes = self.fig.add_subplot(1, 1, 1, projection='3d')
            pass
        self.axes.hold(False)
        self.compute_initial_figure()
        self.setParent(parent)
        FigureCanvas.setSizePolicy(self,
                                   QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

    def compute_initial_figure(self):
        pass

    def export_pdf(self):
        fname='export.pdf'
        self.fig.savefig(fname)

    def export_jpg(self):
        fname='export.jpg'
        self.fig.savefig(fname)
开发者ID:ChrisQuignon,项目名称:ECTA,代码行数:32,代码来源:visualize_results.py

示例8: create_input_graph

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
 def create_input_graph(self, parent, sizer):
     """
     Creates a graph that plots the input
     It returns a timer what starts the plotting
     """
     graph_panel = wx.Panel(parent, size=(320,0))
     self.input_data_generator = DataGen(self)
     self.data_input = []
     dpi = 160
     fig = Figure((2.0, 1.0), dpi=dpi)
     self.axes_input = fig.add_subplot(111)
     fig.add_subplot()
     fig.subplots_adjust(bottom=0.009,left=0.003,right=0.997, top=0.991)
     self.axes_input.set_axis_bgcolor('black')
     pylab.setp(self.axes_input.get_xticklabels(), fontsize=4)
     pylab.setp(self.axes_input.get_yticklabels(), fontsize=4)        
     self.plot_data_input = self.axes_input.plot(self.data_input, 
         linewidth=1,
         color=(1, 0, 0),
         )[0] 
     self.axes_input.grid(True, color='gray')
     self.canvas_input = FigCanvas(graph_panel, -1, fig)        
     vbox = wx.BoxSizer(wx.VERTICAL)
     vbox.Add(self.canvas_input, 0)        
     graph_panel.SetSizer(vbox)
     sizer.Add(graph_panel, 0, wx.TOP | wx.BOTTOM, 5)
     self.axes_input.set_xbound(lower=0, upper=100)
     self.axes_input.set_ybound(lower=-1.0, upper=1.0)
     redraw_timer_input = MyThread(self.graph_refresh_time, self.on_redraw_graph, self) #wx.Timer(self)
     return redraw_timer_input
开发者ID:EQ4,项目名称:DigitalPedalBoard,代码行数:32,代码来源:gui.py

示例9: draw_graph

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
def draw_graph():
    fig=Figure()
    
    # histogram
    ax=fig.add_subplot(211)
    hist_x=np.arange(0, 1, bin_size)
    ax.bar(hist_x, fidelity_bins, width=bin_size, facecolor='#6666ff')
    ax.set_xlabel('Fidelity')
    ax.set_ylabel('Frequency')
    ax.set_xlim(minf*0.95, maxf)
    label='Mean Fidelity=%.4f' % fidelity_mean
    ax.text(0.025, 0.95, label, transform=ax.transAxes, fontsize=10, va='top')
    label='Worst Fidelity=%.4f' % minf
    ax.text(0.025, 0.85, label, transform=ax.transAxes, fontsize=10, va='top')
    
    # trace
    ax=fig.add_subplot(212)
    
    N=len(data_coincidences)
    if N>2:
        t=range(N)
        (ar,br)=np.polyfit(t,data_coincidences,1)
        xr=np.polyval([ar,br],t)
        ax.plot(xr, '--', color='#aaaaaa')
    
    ax.plot(data_coincidences, 'b.')
    ax.plot(data_coincidences, 'b-')
    ax.plot(data_accidentals, 'r.')
    ax.plot(data_accidentals, 'r-')
    ax.set_ylabel('Coincidences')
    ax.set_xlabel('Time')
    
    canvas = FigureCanvasAgg(fig)
    canvas.print_figure('output/%s.pdf' % start_time, dpi=100)
开发者ID:peteshadbolt,项目名称:lab_code,代码行数:36,代码来源:fidelity_histogram.py

示例10: plots

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
def plots( ndata, peaks ) : 
    n,bins = np.histogram(ndata,256)

    fig = Figure(figsize=(8.5,11))

    # plot the histogram
    ax = fig.add_subplot(211)
    ax.grid()
    # don't plot min/max (avoid the clipped pixels)
#    ax.plot(n[1:255])
    ax.plot(n)

    # plot the peaks
    x = peaks
    y = [ n[p] for p in peaks ]
    ax.plot( x, y, 'rx' )

    ax = fig.add_subplot(212)
    ax.grid()
    ax.plot( np.diff(n) )

    # plot the row avg down the page
#    ax = fig.add_subplot(313)
#    ax.grid()
#    ax.plot([ np.mean(row) for row in ndata[:,]])

    outfilename = "out.png"
    canvas = FigureCanvasAgg(fig)
    canvas.print_figure(outfilename)
    print "wrote",outfilename
开发者ID:linuxlizard,项目名称:q60,代码行数:32,代码来源:autowhite.py

示例11: create_output_graph

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
 def create_output_graph(self, parent, sizer):
     """
     Creates a graph that plots the output
     """
     graph_panel = wx.Panel(parent, size=(320,0))
     self.data_output = []
     dpi = 160
     fig = Figure((2.0, 1.0), dpi=dpi)
     self.axes_output = fig.add_subplot(111)
     fig.add_subplot()
     fig.subplots_adjust(bottom=0.009,left=0.003,right=0.997, top=0.991)
     self.axes_output.set_axis_bgcolor('black')
     pylab.setp(self.axes_output.get_xticklabels(), fontsize=4)
     pylab.setp(self.axes_output.get_yticklabels(), fontsize=4)        
     self.plot_data_output = self.axes_output.plot(self.data_output, 
         linewidth=1,
         color=(0, 0, 1),
         )[0] 
     self.axes_output.grid(True, color='gray')
     self.canvas_output = FigCanvas(graph_panel, -1, fig)        
     vbox = wx.BoxSizer(wx.VERTICAL)
     vbox.Add(self.canvas_output, 0)        
     graph_panel.SetSizer(vbox)
     sizer.Add(graph_panel, 0, wx.TOP | wx.BOTTOM, 5)
     self.axes_output.set_xbound(lower=0, upper=100)
     self.axes_output.set_ybound(lower=-1.0, upper=1.0)
开发者ID:EQ4,项目名称:DigitalPedalBoard,代码行数:28,代码来源:gui.py

示例12: plotgraph

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
def plotgraph(window):
    global df2, indexes, f, a, b

    f = Figure()

    plot_df = df2.ix[indexes]
    plot_df = plot_df.set_index('Particulars')

    if graph == 1:
        a = f.add_subplot(211)
        b = f.add_subplot(212)

        a.clear()
        b.clear()

        plot_df1 = plot_df.T
        plot_df1.plot(ax=a, title='% Change of Particulars in Income Statement as Trends')
        plot_df1.plot(ax=b, kind='barh', title='% Change of Particulars in Income Statement as Bars')
        f.subplots_adjust(left=0.2,bottom=0.2,hspace=0.5)
    elif graph == 2:
        a = f.add_subplot(111)
        a.clear()
        plot_df.plot(ax=a, kind='barh', title='% Change of Particulars in Income Statement as Bars')
        f.subplots_adjust(left=0.2,bottom=0.2,hspace=0.5)
    canvas = FigureCanvasTkAgg(f, window)
    canvas.show()
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)

    toolbar = NavigationToolbar2TkAgg(canvas, window)
    toolbar.update()
    canvas._tkcanvas.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
开发者ID:ohmtrivedi,项目名称:NIRMAWorks,代码行数:33,代码来源:Dashboard.py

示例13: main

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
def main(A):
    delta, pos, id = getforest(A, 
            Zmin=2.0, Zmax=2.2, RfLamMin=1040, RfLamMax=1185, combine=4)
    print len(pos)
    print pos, delta
    data = correlate.field(pos, value=delta)
    DD = correlate.paircount(data, data, correlate.RBinning(160000, 40))
    r = DD.centers
    xi = DD.sum1 / DD.sum2
    print r.shape, xi.shape
    numpy.savez(os.path.join(A.datadir, 'delta-corr1d-both.npz'), r=r, xi=xi)

    figure = Figure(figsize=(4, 5), dpi=200)
    ax = figure.add_subplot(311)
    ax.plot(r / 1000, (r / 1000) ** 2 * xi[0], 'o ', label='$dF$ RSD')
    ax.set_ylim(-0.4, 1.0)
    ax.legend()
    ax = figure.add_subplot(312)
    ax.plot(r / 1000, (r / 1000) ** 2 * xi[1], 'o ', label='$dF$ Real')
    ax.set_ylim(-0.4, 1.0)
    ax.legend()
    ax = figure.add_subplot(313)
    ax.plot(r / 1000, (r / 1000) ** 2 * xi[2], 'o ', label=r'$dF$ Broadband')
    ax.set_ylim(-20, 60)
    ax.legend()
    canvas = FigureCanvasAgg(figure)
    figure.savefig(os.path.join(A.datadir, 'delta-corr-both.svg'))
开发者ID:rainwoodman,项目名称:lyamock,代码行数:29,代码来源:pixelcorr.py

示例14: Canvas

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
class Canvas(FigureCanvas):
    """Matplotlib Figure widget to display CPU utilization"""
    def __init__(self, parent, ionCatalogArray, ionSwapCatalog):
        self.parent = parent
        self.fig = Figure()
        FigureCanvas.__init__(self, self.fig)

        self.ax1 = self.fig.add_subplot(131)
        self.ax2 = self.fig.add_subplot(132)
        self.ax3 = self.fig.add_subplot(133)
        
        self.setHist(self.ax2, ionCatalogArray[0], label = 'initial')
        self.setHist(self.ax3, ionCatalogArray[1], label = 'final')
        
        self.ax1.set_xlabel('Number Of Dark Ions')
        self.ax1.text(.35, .75, str((len(np.where(np.array(ionCatalogArray[0]) == 1)[0])/float(len(ionCatalogArray[0])))*100) + ' percent w/ one ion dark', fontsize=12, transform = self.ax1.transAxes)
        self.ax1.text(.35, .8, 'Mean: ' + str(np.mean(ionCatalogArray[0])) + ' ions dark', transform = self.ax1.transAxes)
        self.ax1.set_ylim(0, 1)
        self.ax2.set_xlabel('Number Of Dark Ions')
        self.ax2.text(.35, .75, str((len(np.where(np.array(ionCatalogArray[1]) == 1)[0])/float(len(ionCatalogArray[1])))*100) + ' percent w/ one ion dark', fontsize=12, transform = self.ax2.transAxes)
        self.ax2.text(.35, .8, 'Mean: ' + str(np.mean(ionCatalogArray[1])) + ' ions dark', transform = self.ax2.transAxes)
        self.ax2.set_ylim(0, 1)

        self.ax3.hist(ionSwapCatalog, bins=range(self.parent.parent.expectedNumberOfIonsSpinBox.value() + 1), align='left', normed = True, label = 'Ion Swaps' )
        self.ax3.legend(loc='best')
        self.ax3.set_xlabel('Distance of Ion Movement')
        self.ax3.text(.25, .8, 'Number Ion Swaps: ' + str(len(np.where(np.array(ionSwapCatalog) == 1)[0])), transform = self.ax3.transAxes)
        self.ax3.text(0.025, .75, '1 ion dark in both shine729 and final: ' + str(len(ionSwapCatalog)/float(len(ionCatalogArray[0]))*100) + ' %', transform = self.ax3.transAxes)
        self.ax3.text(0.10, .70, 'Probability of Ion Swap: ' + str(len(np.where(np.array(ionSwapCatalog) == 1)[0])/float(len(ionSwapCatalog))), transform = self.ax3.transAxes)

    def setHist(self, ax, data, label):
        ax.hist(data, bins=range(10), align='left', normed=True, label = label)
        ax.legend(loc='best')
开发者ID:HaeffnerLab,项目名称:sqip,代码行数:35,代码来源:ionSwapCameraClient2ndGen.py

示例15: CanvasPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import add_subplot [as 别名]
class CanvasPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

    def show_data(self,fbfile,fields=['cond','imu_a']):
        if fbfile.data is None:
            return
        
        self.figure.clear()
        
        axs=[]
        for axi,varname in enumerate(fields):
            if axi==0:
                sharex=None
            else:
                sharex=axs[0]

            ax=self.figure.add_subplot(len(fields),1,axi+1,sharex=sharex)
            axs.append(ax)
            ax.plot_date( fbfile.data['dn_py'],
                          fbfile.data[varname],
                          'g-')
            
        self.figure.autofmt_xdate()

        # Not sure how to trigger it to actually draw things.
        self.canvas.draw()
        self.Fit()
开发者ID:rustychris,项目名称:freebird,代码行数:37,代码来源:data_gui.py


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