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


Python Figure.gca方法代码示例

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


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

示例1: SunPyPlot

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
class SunPyPlot(FigureCanvas):
    """SunPy preview image"""

    def __init__(self, map_, width, height, parent=None, dpi=100, **matplot_args):  # pylint: disable=W0613
        # self._widthHint = width
        # self._heightHint = height

        self._origMap = map_
        self._map = map_.resample((width, height))

        # Old way (segfaults in some environements)
        # self.figure = self._map.plot_simple(**matplot_args)
        # FigureCanvas.__init__(self, self.figure)

        self.figure = Figure()
        self._map.plot(figure=self.figure, basic_plot=True, **matplot_args)
        self.axes = self.figure.gca()
        FigureCanvas.__init__(self, self.figure)

        # How can we get the canvas to preserve its aspect ratio when expanding?
        # sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
        # sizePolicy.setHeightForWidth(True)
        # self.setSizePolicy(sizePolicy)

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
        self.setSizePolicy(sizePolicy)
        self.setMinimumSize(QtCore.QSize(width, height))
        self.setMaximumSize(QtCore.QSize(width, height))
开发者ID:katrienbonte,项目名称:sunpy,代码行数:30,代码来源:rgb_composite.py

示例2: CDF

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
class CDF(tk.Toplevel):
    def __init__(self, master, name, data):
        tk.Toplevel.__init__(self, master)
        self.wm_title("CDF: {}".format(name))

        self.fig = Figure(figsize=(4,3), dpi=100)
        canvas = FigureCanvasTkAgg(self.fig, self)
        canvas.get_tk_widget().pack(fill=tk.BOTH, expand=1)
        toolbar = NavigationToolbar2TkAgg(canvas, self)


        menubar = tk.Menu(self)
        menubar.add_command(label="Save Data", command=self.save)
        self.config(menu=menubar)

        ax = self.fig.gca()
        ax.set_title(name)
        self.x, self.y = ae.cdf(data)
        
        ax.plot(self.x, self.y, "o")
        ax.loglog()
        ax.grid(True)

        self.update()

    def save(self):
        from numpy import savetxt, transpose
        fname = tkFileDialog.asksaveasfilename(parent=self, 
                    filetypes=[('Data file', '.txt .dat')])
        if fname:
            savetxt(fname, transpose([self.x, self.y]))
开发者ID:zhangwise,项目名称:ae,代码行数:33,代码来源:AEViewer.py

示例3: generate_scatterplot

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
def generate_scatterplot(datafname, imgfname):
    """Creates a 2D scatter plot of the specified Gocator XYZ
    data and saves it in the specified image filename."""
    matplotlib.rcParams['axes.formatter.limits'] = -4, 4
    matplotlib.rcParams['font.size'] = 14
    matplotlib.rcParams['axes.titlesize'] = 12
    matplotlib.rcParams['axes.labelsize'] = 12
    matplotlib.rcParams['xtick.labelsize'] = 11
    matplotlib.rcParams['ytick.labelsize'] = 11
    figure = Figure()
    canvas = FigureCanvas(figure)
    axes = figure.gca()
    x,y,z = np.genfromtxt(datafname, delimiter=",", unpack=True)
    xi = x[z!=-32.768]
    yi = y[z!=-32.768]
    zi = z[z!=-32.768]
    scatter_plt = axes.scatter(xi, yi, c=zi, cmap=cm.get_cmap("Set1"), marker=',')
    axes.grid(True)
    axes.axis([np.min(xi), np.max(xi), np.min(yi), np.max(yi)])
    axes.set_title(os.path.basename(datafname))
    colorbar = figure.colorbar(scatter_plt)
    colorbar.set_label("Range [mm]")
    axes.set_xlabel("Horizontal Position [mm]")
    axes.set_ylabel("Scan Position [mm]")
    figure.savefig(imgfname)
开发者ID:badrobot25,项目名称:gocator_profiler,代码行数:27,代码来源:batch_plotter.py

示例4: preprocess

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
  def preprocess(self, low=0.32, high=2.55, UV=0, fit_order=1, idx_in=3):
    
    plt.close('all')  # hack!
    low, high, UV = float(low), float(high), float(UV)
    self.pp_bounds = (low, high, UV)
    fit_order = int(fit_order)
    idx_in = int(idx_in)

    if self.hapke_scalar.needs_isow:
      # initialize isow as a scalar
      isoind1, isoind2 = np.searchsorted(self.calspec[:,0], (low, high))
      self.hapke_scalar.set_isow(self.calspec[isoind1:isoind2,1].mean())

    # run preprocessing on each spectrum
    for key, traj in self.spectra.items():
      self.pp_spectra[key] = analysis.preprocess_traj(traj, low, high, UV,
                                                      fit_order=fit_order, idx = idx_in)

    # plot the results
    fig = Figure(figsize=(6, 4), frameon=False, tight_layout=True)
    ax = fig.gca()

    #If additional files exist we plot them 
    for k in self.pp_spectra:
        ax.plot(*self.pp_spectra[k].T, label=k)

    ax.legend(fontsize='small', loc='best')
    ax.set_title('Preprocessed spectra')
    ax.set_xlabel('Wavelength ($\mu{}m)$')
    ax.set_ylabel('Reflectance')
    #pp is the parameter used for identifying the download data.
    return 'Preprocessing complete: ', 'pp', [fig]
开发者ID:asudhakar-umass,项目名称:HappyHapke,代码行数:34,代码来源:prog_state.py

示例5: sample_fits

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
def sample_fits(mcmc_set):
    tspan = mcmc_set.chains[0].options.tspan
    fig = Figure()
    ax = fig.gca()
    plot_filename = '%s_sample_fits.png' % mcmc_set.name
    thumbnail_filename = '%s_sample_fits_th.png' % mcmc_set.name

    # Make sure we can call the method 'get_observable_timecourses'
    if not hasattr(mcmc_set.chains[0], 'get_observable_timecourses') or \
       not hasattr(mcmc_set.chains[0], 'plot_data'):
        return Result('None', None)

    # Plot the original data
    mcmc_set.chains[0].plot_data(ax)

    # Plot a sampling of trajectories from the original parameter set
    try:
        for i in range(num_samples):
            position = mcmc_set.get_sample_position()
            timecourses = mcmc_set.chains[0].get_observable_timecourses(
                                                                position=position)
            for obs_name, timecourse in timecourses.iteritems():
                ax.plot(tspan, timecourse, color='g', alpha=0.1, label=obs_name)
    except NoPositionsException as npe:
        pass

    canvas = FigureCanvasAgg(fig)
    fig.set_canvas(canvas)
    fig.savefig(plot_filename)
    fig.savefig(thumbnail_filename, dpi=10)

    return ThumbnailResult(thumbnail_filename, plot_filename)
开发者ID:jmuhlich,项目名称:bayessb,代码行数:34,代码来源:reporters.py

示例6: residuals_at_max_likelihood

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
def residuals_at_max_likelihood(mcmc_set):
    # Get the maximum likelihood parameters
    try:
        (max_likelihood, max_likelihood_position) = mcmc_set.maximum_likelihood()
    except NoPositionsException as npe:
        return Result(None, None)

    # Get the residuals
    residuals = mcmc_set.chains[0].get_residuals(max_likelihood_position)

    # Make the residuals plot
    fig = Figure()
    ax = fig.gca()
    plot_filename = '%s_max_likelihood_residuals.png' % mcmc_set.name
    thumbnail_filename = '%s_max_likelihood_residuals_th.png' % mcmc_set.name
    ax.plot(residuals[0], residuals[1])
    ax.set_title('Residuals at Maximum Likelihood')
    #ax.xlabel('Time')
    #ax.ylabel('Residual')
    canvas = FigureCanvasAgg(fig)
    fig.set_canvas(canvas)
    fig.savefig(plot_filename)
    fig.savefig(thumbnail_filename, dpi=10)

    return ThumbnailResult(thumbnail_filename, plot_filename)
开发者ID:johnbachman,项目名称:tBidBaxLipo,代码行数:27,代码来源:residuals.py

示例7: Matplotlib1DWidget

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

        def __init__(self, parent, grid, count, vmin=None, vmax=None, legend=None, codim=1, dpi=100):
            assert grid.reference_element is line
            assert codim in (0, 1)

            self.figure = Figure(dpi=dpi)
            self.axes = self.figure.gca()
            self.axes.hold(True)
            lines = tuple()
            for _ in xrange(count):
                l, = self.axes.plot(grid.centers(codim), np.zeros_like(grid.centers(codim)))
                lines = lines + (l,)
            self.axes.set_ylim(vmin, vmax)
            if legend:
                self.axes.legend(legend)
            self.lines = lines

            super(Matplotlib1DWidget, self).__init__(self.figure)
            self.setParent(parent)
            self.setMinimumSize(300, 300)
            self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        def set(self, U, ind):
            for line, u in izip(self.lines, U):
                line.set_ydata(u[ind])
            self.draw()
开发者ID:BarbaraV,项目名称:pymor,代码行数:29,代码来源:matplotlib.py

示例8: acf_of_ml_residuals

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
def acf_of_ml_residuals(mcmc_set):
    # Get the maximum likelihood parameters
    try:
        (max_likelihood, max_likelihood_position) = mcmc_set.maximum_likelihood()
    except NoPositionsException as npe:
        return Result(None, None)

    # Get the residuals
    residuals = mcmc_set.chains[0].get_residuals(max_likelihood_position)

    # Plot the autocorrelation function
    acf = np.correlate(residuals[1], residuals[1], mode='full')

    plot_filename = '%s_acf_of_ml_residuals.png' % mcmc_set.name
    thumbnail_filename = '%s_acf_of_ml_residuals_th.png' % mcmc_set.name
    fig = Figure()
    ax = fig.gca()
    ax.plot(acf)
    ax.set_title('Autocorrelation of Maximum Likelihood Residuals')

    canvas = FigureCanvasAgg(fig)
    fig.set_canvas(canvas)
    fig.savefig(plot_filename)
    fig.savefig(thumbnail_filename, dpi=10)

    return ThumbnailResult(thumbnail_filename, plot_filename)
开发者ID:johnbachman,项目名称:tBidBaxLipo,代码行数:28,代码来源:residuals.py

示例9: tBidBax_kd

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
def tBidBax_kd(mcmc_set):
    """ .. todo:: document the basis for this"""
    num_kds = 10000
    # Get indices for the tBid/Bax binding constants
    estimate_params = mcmc = mcmc_set.chains[0].options.estimate_params
    tBid_iBax_kf_index = None
    tBid_iBax_kr_index = None
    for i, p in enumerate(estimate_params):
        if p.name == 'tBid_iBax_kf':
            tBid_iBax_kf_index = i
        elif p.name == 'tBid_iBax_kr':
            tBid_iBax_kr_index = i
    # If we couldn't find the parameters, return None for the result
    if tBid_iBax_kf_index is None or tBid_iBax_kr_index is None:
        return Result(None, None)
    # Sample the kr/kf ratio across the pooled chains
    kd_dist = np.zeros(num_kds)
    for i in range(num_kds):
        position = mcmc_set.get_sample_position()
        kd_dist[i] = ((10 ** position[tBid_iBax_kr_index]) /
                      (10 ** position[tBid_iBax_kf_index]))
    # Calculate the mean and variance
    mean = kd_dist.mean()
    sd = kd_dist.std()

    # Plot the Kd distribution
    plot_filename = '%s_tBidiBax_kd_dist.png' % mcmc_set.name
    fig = Figure()
    ax = fig.gca()
    ax.hist(kd_dist)
    canvas = FigureCanvasAgg(fig)
    fig.set_canvas(canvas)
    fig.savefig(plot_filename)

    return MeanSdResult(mean, sd, plot_filename)
开发者ID:johnbachman,项目名称:tBidBaxLipo,代码行数:37,代码来源:knowledge.py

示例10: Histogram

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
class Histogram(tk.Toplevel):
    def __init__(self, master, name, data):
        tk.Toplevel.__init__(self, master)
        self.wm_title("Histogram: {}".format(name))

        self.fig = Figure(figsize=(4,3), dpi=100)
        canvas = FigureCanvasTkAgg(self.fig, self)
        canvas.get_tk_widget().pack(fill=tk.BOTH, expand=1)
        toolbar = NavigationToolbar2TkAgg(canvas, self)


        menubar = tk.Menu(self)
        menubar.add_command(label="Save Data", command=self.save)
        self.config(menu=menubar)

        ax = self.fig.gca()
        ax.set_title(name)
        self.hist, self.bins, _ = ae.hist(data, ax=ax, density=True)

        self.update()

    def save(self):
        from numpy import savetxt, transpose
        fname = tkFileDialog.asksaveasfilename(parent=self, 
                    filetypes=[('Data file', '.txt .dat')])
        if fname:
            savetxt(fname, transpose([self.bins[:-1], self.bins[1:], self.hist]))
开发者ID:zhangwise,项目名称:ae,代码行数:29,代码来源:AEViewer.py

示例11: plot_parameter_curve

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
def plot_parameter_curve(mcmc_set, p_index, p_name):
    # Make sure we've already run the fits for this mcmc set!
    if mcmc_set.name not in two_exp_fits_dict.keys():
        raise Exception('%s not found in two_exp_fits_dict!' % mcmc_set.name)
    # Make sure we've already run the fits for the data!
    if 'data' not in two_exp_fits_dict.keys():
        fit_data(mcmc_set)

    # Get the parameter array
    p_arr = two_exp_fits_dict[mcmc_set.name][p_index]
    p_arr_data = two_exp_fits_dict['data'][p_index]
    data = mcmc_set.chains[0].data
    plot_filename = '%s_%s_curve.png' % (mcmc_set.name, p_name)
    thumbnail_filename = '%s_%s_curve_th.png' % (mcmc_set.name, p_name)

    # Plot of parameter
    fig = Figure()
    ax = fig.gca()
    ax.plot(data.columns, p_arr, 'b')
    ax.plot(data.columns, p_arr_data, marker='o', linestyle='', color='r')
    ax.set_ylabel('%s value' % p_name)
    ax.set_xlabel('[Bax] (nM)')
    ax.set_title('%s for %s' % (mcmc_set.name, p_name))
    canvas = FigureCanvasAgg(fig)
    fig.set_canvas(canvas)
    fig.savefig(plot_filename)
    fig.savefig(thumbnail_filename, dpi=10)
    return ThumbnailResult(thumbnail_filename, plot_filename)
开发者ID:johnbachman,项目名称:tBidBaxLipo,代码行数:30,代码来源:titration_fits.py

示例12: PlotPlotPanel

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
class PlotPlotPanel(wx.Panel):
    def __init__(self, parent, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, **kwargs)
        self.ztv_frame = self.GetTopLevelParent()
        self.figure = Figure(dpi=None, figsize=(1.,1.))
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
        self.Bind(wx.EVT_SIZE, self._onSize)
        self.axes_widget = AxesWidget(self.figure.gca())
        self.axes_widget.connect_event('motion_notify_event', self.on_motion)
        self.plot_point = None
        
    def on_motion(self, evt):
        if evt.xdata is not None:
            xarg = np.abs(self.ztv_frame.plot_panel.plot_positions - evt.xdata).argmin()
            ydata = self.ztv_frame.plot_panel.plot_im_values[xarg]
            self.ztv_frame.plot_panel.cursor_position_textctrl.SetValue('{0:.6g},{1:.6g}'.format(evt.xdata, ydata))
            if self.plot_point is None:
                self.plot_point, = self.axes.plot([evt.xdata], [ydata], 'xm')
            else:
                self.plot_point.set_data([[evt.xdata], [ydata]])
            self.figure.canvas.draw()

    def _onSize(self, event):
        self._SetSize()

    def _SetSize(self):
        pixels = tuple(self.GetClientSize())
        self.SetSize(pixels)
        self.canvas.SetSize(pixels)
        self.figure.set_size_inches(float(pixels[0])/self.figure.get_dpi(), float(pixels[1])/self.figure.get_dpi())
开发者ID:henryroe,项目名称:ztv,代码行数:33,代码来源:plot_panel.py

示例13: initialize

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
	def initialize(self):
		fig = Figure(facecolor=(0.7490196,0.7490196,0.7490196,1), tight_layout=True)
		self.canvas = FigureCanvasWxAgg(self, -1, fig)
		self.canvas.SetExtraStyle(wx.EXPAND)
		self.ax = fig.gca(projection='3d', axisbg=(0.7490196,0.7490196,0.7490196,1))

		self.Bind(wx.EVT_SIZE, self.onSize)
		self.Layout()
开发者ID:Claude59,项目名称:horus,代码行数:10,代码来源:pages.py

示例14: plot_emcee_fits

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import gca [as 别名]
def plot_emcee_fits(gf, sampler, sample=True, burn=None, nsamples=100,
                    plot_filename=None):
    """Plot fits from the MCMC chain vs. the data."""
    if not DISPLAY and plot_filename is None:
        raise ValueError("DISPLAY is set to False but plot_filename is None, "
                         "so there will be no output.")
    set_fig_params_for_publication()
    # If we're plotting samples, get the indices now and use them for
    # all observables
    if sample:
        (nwalkers, nsteps) = sampler.chain.shape[1:3]
        if burn is None:
            burn = int(nsteps / 2)

        walker_indices = np.random.randint(0, nwalkers, size=nsamples)
        step_indices = np.random.randint(burn, nsteps, size=nsamples)

    for obs_ix in range(gf.data.shape[1]):
        if DISPLAY:
            fig = plt.figure(figsize=(3, 3), dpi=300)
        else:
            fig = Figure(figsize=(3, 3), dpi=300)

        ax = fig.gca()
        ax.set_ylabel('$F/F_0$')
        #ax.set_xlabel(r'Time (sec $\times 10^3$)')
        ax.set_xlabel(r'Time')
        #plt.ylim([0.7, 5.2])
        ax.set_xlim([0, gf.time[-1] + 500])
        #ax.set_xticks(np.linspace(0, 1e4, 6))
        #ax.set_xticklabels([int(f) for f in np.linspace(0, 10, 6)])
        fig.subplots_adjust(bottom=0.21, left=0.20)
        # Plot the different observables
        for cond_ix in range(gf.data.shape[0]):
            data = gf.data[cond_ix, obs_ix, :]
            ax.plot(gf.time, data, 'k', linewidth=1)
        # Colors for different observables
        obs_colors = ['r', 'g', 'b', 'k']
        # If we're plotting samples:
        if sample:
            for i in xrange(nsamples):
                p = sampler.chain[0, walker_indices[i], step_indices[i], :]
                plot_args = {'color': obs_colors[obs_ix], 'alpha': 0.1}
                gf.plot_func(p, obs_ix=obs_ix, ax=ax, plot_args=plot_args)

        # Plot the maximum a posteriori fit
        maxp_flat_ix = np.argmax(sampler.lnprobability[0])
        maxp_ix = np.unravel_index(maxp_flat_ix,
                                   sampler.lnprobability[0].shape)
        maxp = sampler.lnprobability[0][maxp_ix]
        plot_args = {'color': 'm', 'alpha': 1}
        gf.plot_func(sampler.chain[0, maxp_ix[0], maxp_ix[1]], ax=ax,
                     obs_ix=obs_ix, plot_args=plot_args)

        format_axis(ax)
        if plot_filename:
            obs_plot_filename = '%s.obs%d' % (plot_filename, obs_ix)
            save_fig(fig, obs_plot_filename, DISPLAY)
开发者ID:johnbachman,项目名称:tBidBaxLipo,代码行数:60,代码来源:show_chain.py

示例15: MatplotlibWidget

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

    def __init__(self, parent=None):
        super(MatplotlibWidget, self).__init__(Figure())

        self.setParent(parent)
        self.figure = Figure()
        self.canvas = FigureCanvas(self.figure)
        self.axes = self.figure.gca()
开发者ID:luispedro,项目名称:rbit,代码行数:11,代码来源:MatplotlibWidget.py


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