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


Python pylab.gcf方法代码示例

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


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

示例1: copy_figure_to_clipboard

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def copy_figure_to_clipboard(figure='gcf'):
    """
    Copies the specified figure to the system clipboard. Specifying 'gcf'
    will use the current figure.
    """    
    try:
        import pyqtgraph as _p
    
        # Get the current figure if necessary        
        if figure is 'gcf': figure = _s.pylab.gcf() 
        
        # Store the figure as an image
        path = _os.path.join(_s.settings.path_home, "clipboard.png")
        figure.savefig(path)
        
        # Set the clipboard. I know, it's weird to use pyqtgraph, but 
        # This covers both Qt4 and Qt5 with their Qt4 wrapper!
        _p.QtGui.QApplication.instance().clipboard().setImage(_p.QtGui.QImage(path))
        
    except:         
        print("This function currently requires pyqtgraph to be installed.") 
开发者ID:Spinmob,项目名称:spinmob,代码行数:23,代码来源:_pylab_tweaks.py

示例2: get_figure_window_geometry

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def get_figure_window_geometry(fig='gcf'):
    """
    This will currently only work for Qt4Agg and WXAgg backends.
    Returns position, size

    postion = [x, y]
    size    = [width, height]

    fig can be 'gcf', a number, or a figure object.
    """

    if type(fig)==str:          fig = _pylab.gcf()
    elif _fun.is_a_number(fig): fig = _pylab.figure(fig)

    # Qt4Agg backend. Probably would work for other Qt stuff
    if _pylab.get_backend().find('Qt') >= 0:
        size = fig.canvas.window().size()
        pos  = fig.canvas.window().pos()
        return [[pos.x(),pos.y()], [size.width(),size.height()]]

    else:
        print("get_figure_window_geometry() only implemented for QtAgg backend.")
        return None 
开发者ID:Spinmob,项目名称:spinmob,代码行数:25,代码来源:_pylab_tweaks.py

示例3: on_epoch_end

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def on_epoch_end(self, epoch, logs={}):
        self.model.save_weights(os.path.join(self.output_dir, 'weights%02d.h5' % (epoch)))
        self.show_edit_distance(256)
        word_batch = next(self.text_img_gen)[0]
        res = decode_batch(self.test_func, word_batch['the_input'][0:self.num_display_words])
        if word_batch['the_input'][0].shape[0] < 256:
            cols = 2
        else:
            cols = 1
        for i in range(self.num_display_words):
            pylab.subplot(self.num_display_words // cols, cols, i + 1)
            if K.image_data_format() == 'channels_first':
                the_input = word_batch['the_input'][i, 0, :, :]
            else:
                the_input = word_batch['the_input'][i, :, :, 0]
            pylab.imshow(the_input.T, cmap='Greys_r')
            pylab.xlabel('Truth = \'%s\'\nDecoded = \'%s\'' % (word_batch['source_str'][i], res[i]))
        fig = pylab.gcf()
        fig.set_size_inches(10, 13)
        pylab.savefig(os.path.join(self.output_dir, 'e%02d.png' % (epoch)))
        pylab.close() 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:23,代码来源:image_ocr.py

示例4: save_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def save_plot(self, filename):
        plt.ion()
        targarr = np.array(self.targvalue)
        self.posi[0].set_xdata(self.wt_positions[:,0])
        self.posi[0].set_ydata(self.wt_positions[:,1])
        while len(self.plotel)>0:
            self.plotel.pop(0).remove()
        self.plotel = self.shape_plot.plot(np.array([self.wt_positions[[i,j],0] for i, j in self.elnet_layout.keys()]).T,
                                   np.array([self.wt_positions[[i,j],1]  for i, j in self.elnet_layout.keys()]).T, 'y-', linewidth=1)
        for i in range(len(self.posb)):
            self.posb[i][0].set_xdata(self.iterations)
            self.posb[i][0].set_ydata(targarr[:,i])
            self.legend.texts[i].set_text('%s = %8.2f'%(self.targname[i], targarr[-1,i]))
        self.objf_plot.set_xlim([0, self.iterations[-1]])
        self.objf_plot.set_ylim([0.5, 1.2])
        if not self.title == '':
            plt.title('%s = %8.2f'%(self.title, getattr(self, self.title)))
        plt.draw()
        #print self.iterations[-1] , ': ' + ', '.join(['%s=%6.2f'%(self.targname[i], targarr[-1,i]) for i in range(len(self.targname))])
        with open(self.result_file+'.results','a') as f:
            f.write( '%d:'%(self.inc) + ', '.join(['%s=%6.2f'%(self.targname[i], targarr[-1,i]) for i in range(len(self.targname))]) +
                '\n')
        #plt.show()
        #plt.savefig(filename)
        display(plt.gcf())
        #plt.show()
        clear_output(wait=True) 
开发者ID:DTUWindEnergy,项目名称:TOPFARM,代码行数:29,代码来源:plot.py

示例5: generateImages

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def generateImages(picklefile, pickledir, filehash, imagedir, pietype):

	leaf_file = open(os.path.join(pickledir, picklefile), 'rb')
	(piedata, pielabels) = cPickle.load(leaf_file)
	leaf_file.close()

	pylab.figure(1, figsize=(6.5,6.5))
	ax = pylab.axes([0.2, 0.15, 0.6, 0.6])

	pylab.pie(piedata, labels=pielabels)

	pylab.savefig(os.path.join(imagedir, '%s-%s.png' % (filehash, pietype)))
	pylab.gcf().clear()
	os.unlink(os.path.join(pickledir, picklefile)) 
开发者ID:armijnhemel,项目名称:binaryanalysis,代码行数:16,代码来源:piecharts.py

示例6: test_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def test_plot():
    time = np.arange(N_SAMPLES)*1e-3
    sample = np.random.randn(N_SAMPLES)
    plt.plot(time, sample, label="Gaussian noise")
    plt.title("1000s Timetrace \n (use the slider to scroll and the spin-box "
              "to set the width)")
    plt.xlabel('Time (s)')
    plt.legend(fancybox=True)
    q = ScrollingToolQT(plt.gcf(), scroll_step=1)
    return q   # WARNING: it's important to return this object otherwise
               # python will delete the reference and the GUI will not respond! 
开发者ID:tritemio,项目名称:FRETBursts,代码行数:13,代码来源:timetrace_scroll_demo.py

示例7: test_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def test_plot():
    dx = 1e-3 # this is the sampling period (or grid spacing) of `sample`
    sample = np.random.randn(N_SAMPLES)
    line, = plt.plot([], [], label="Gaussian noise")
    plt.legend(fancybox=True)
    plt.title("Use the slider to scroll and the spin-box to set the width")
    q = ScrollingPlotQT(fig=plt.gcf(), line=line, ydata=sample, dx=1e-3)
    return q   # WARNING: it's important to return this object otherwise
               # python will delete the reference and the GUI will not respond! 
开发者ID:tritemio,项目名称:FRETBursts,代码行数:11,代码来源:timetrace_scroll_demo3.py

示例8: save_plots

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def save_plots(self, folder):

        import pylab as pl

        pl.gcf().set_size_inches(15, 15)

        pl.clf()
        self.homography.plot_original()
        pl.savefig(join(folder, 'homography-original.jpg'))

        pl.clf()
        self.homography.plot_rectified()
        pl.savefig(join(folder, 'homography-rectified.jpg'))

        pl.clf()
        self.driving_layers.plot(overlay_alpha=0.7)
        pl.savefig(join(folder, 'segnet-driving.jpg'))

        pl.clf()
        self.facade_layers.plot(overlay_alpha=0.7)
        pl.savefig(join(folder, 'segnet-i12-facade.jpg'))

        pl.clf()
        self.plot_grids()
        pl.savefig(join(folder, 'grid.jpg'))

        pl.clf()
        self.plot_regions()
        pl.savefig(join(folder, 'regions.jpg'))

        pl.clf()
        pl.gcf().set_size_inches(6, 4)
        self.plot_facade_cuts()
        pl.savefig(join(folder, 'facade-cuts.jpg'), dpi=300)
        pl.savefig(join(folder, 'facade-cuts.svg'))

        imsave(join(folder, 'walls.png'), self.wall_colors) 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:39,代码来源:megafacade.py

示例9: plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def plot(self):
        """Visualize the label images (e.g. for debugging)

        :return: The current figure
        """
        import pylab
        pylab.imshow(self.image, interpolation='nearest')
        return pylab.gcf() 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:10,代码来源:import_labelme.py

示例10: plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def plot(self, derivative=0, xmin="auto", xmax="auto", steps=500, smooth=0, simple='auto', clear=True, yaxis='left'):
        if simple=='auto': simple = self.simple

        # get the min and max
        if xmin=="auto": xmin = self.xmin
        if xmax=="auto": xmax = self.xmax

        # get and clear the figure and axes
        f = _pylab.gcf()
        if clear and yaxis=='left': f.clf()

        # setup the right-hand axis
        if yaxis=='right':  a = _pylab.twinx()
        else:               a = _pylab.gca()

        # define a new simple function to plot, then plot it
        def f(x): return self.evaluate(x, derivative, smooth, simple)
        _pylab_help.plot_function(f, xmin, xmax, steps, clear, axes=a)

        # label it
        th = "th"
        if derivative == 1: th = "st"
        if derivative == 2: th = "nd"
        if derivative == 3: th = "rd"
        if derivative: self.ylabel = str(derivative)+th+" derivative of "+self.ylabel+" spline"
        a.set_xlabel(self.xlabel)
        a.set_ylabel(self.ylabel)
        a.figure.canvas.Refresh() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:30,代码来源:_spline.py

示例11: get_figure_window

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def get_figure_window(figure='gcf'):
    """
    This will search through the windows and return the one containing the figure
    """

    if figure == 'gcf': figure = _pylab.gcf()
    return figure.canvas.GetParent() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:9,代码来源:_pylab_tweaks.py

示例12: set_figure_window_geometry

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def set_figure_window_geometry(fig='gcf', position=None, size=None):
    """
    This will currently only work for Qt4Agg and WXAgg backends.

    postion = [x, y]
    size    = [width, height]

    fig can be 'gcf', a number, or a figure object.
    """

    if type(fig)==str:          fig = _pylab.gcf()
    elif _fun.is_a_number(fig): fig = _pylab.figure(fig)

    # Qt4Agg backend. Probably would work for other Qt stuff
    if _pylab.get_backend().find('Qt') >= 0:
        w = fig.canvas.window()

        if not size == None:
            w.resize(size[0],size[1])

        if not position == None:
            w.move(position[0], position[1])

    # WXAgg backend. Probably would work for other Qt stuff.
    elif _pylab.get_backend().find('WX') >= 0:
        w = fig.canvas.Parent

        if not size == None:
            w.SetSize(size)

        if not position == None:
            w.SetPosition(position) 
开发者ID:Spinmob,项目名称:spinmob,代码行数:34,代码来源:_pylab_tweaks.py

示例13: coarsen_all_traces

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def coarsen_all_traces(level=2, exponential=False, axes="all", figure=None):
    """
    This function does nearest-neighbor coarsening of the data. See 
    spinmob.fun.coarsen_data for more information.
    
    Parameters
    ----------
    level=2
        How strongly to coarsen.
    exponential=False
        If True, use the exponential method (great for log-x plots).
    axes="all"
        Which axes to coarsen.
    figure=None
        Which figure to use.
    
    """
    if axes=="gca": axes=_pylab.gca()
    if axes=="all":
        if not figure: f = _pylab.gcf()
        axes = f.axes

    if not _fun.is_iterable(axes): axes = [axes]

    for a in axes:
        # get the lines from the plot
        lines = a.get_lines()

        # loop over the lines and trim the data
        for line in lines:
            if isinstance(line, _mpl.lines.Line2D):
                coarsen_line(line, level, exponential, draw=False)
    _pylab.draw() 
开发者ID:Spinmob,项目名称:spinmob,代码行数:35,代码来源:_pylab_tweaks.py

示例14: export_figure

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def export_figure(dpi=200, figure="gcf", path=None):
    """
    Saves the actual postscript data for the figure.
    """
    if figure=="gcf": figure = _pylab.gcf()

    if path==None: path = _s.dialogs.Save("*.*", default_directory="save_plot_default_directory")

    if path=="":
        print("aborted.")
        return

    figure.savefig(path, dpi=dpi) 
开发者ID:Spinmob,项目名称:spinmob,代码行数:15,代码来源:_pylab_tweaks.py

示例15: save_images

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import gcf [as 别名]
def save_images(self, images, base_filename, flattened=True):
        self.ensure_dir(self.dirname)
        for i in self.saved_image_indices:
            label = self.labels[i].lower().replace(" ", "_")
            image = images[i, :].copy()
            if flattened:
                image = image.reshape(self.image_shape)
            image[np.isnan(image)] = 0
            figure = pylab.gcf()
            axes = pylab.gca()
            extra_kwargs = {}
            if self.color:
                extra_kwargs["cmap"] = "gray"
            assert image.min() >= 0, "Image can't contain negative numbers"
            if image.max() <= 1:
                image *= 256
            image[image > 255] = 255
            axes.imshow(image.astype("uint8"), **extra_kwargs)
            axes.get_xaxis().set_visible(False)
            axes.get_yaxis().set_visible(False)
            filename = base_filename + ".png"
            subdir = join(self.dirname, label)
            self.ensure_dir(subdir)
            path = join(subdir, filename)
            figure.savefig(
                path,
                bbox_inches='tight')
            self.saved_images[i][base_filename] = path 
开发者ID:iskandr,项目名称:fancyimpute,代码行数:30,代码来源:complete_faces.py


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