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


Python PlotGraphicsContext.save方法代码示例

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


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

示例1: OnMenuExportPNG

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
    def OnMenuExportPNG(self, e=None):
        """ Saves plot container as png
        
        """
        dlg = wx.FileDialog(self, "Export plot as PNG", 
                            self.config.GetWorkingDirectory("PNG"), "",
                            "PDF file (*.png)|*.png",
                            wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            if not path.endswith(".png"):
                path += ".png"
            self.config.SetWorkingDirectory(os.path.dirname(path), "PNG")
            container = self.PlotArea.mainplot.container
            
            # get inner_boundary
            p = container

            dpi=600
            p.do_layout(force=True)
            gc = PlotGraphicsContext(tuple(p.outer_bounds), dpi=dpi)

            # temporarily turn off the backbuffer for offscreen rendering
            use_backbuffer = p.use_backbuffer
            p.use_backbuffer = False
            p.draw(gc)
            #gc.render_component(p)

            gc.save(path)

            p.use_backbuffer = use_backbuffer
开发者ID:DerDeef,项目名称:ShapeOut,代码行数:33,代码来源:frontend.py

示例2: _SaveFlag_changed

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
    def _SaveFlag_changed(self):	
	DPI = 72
	print '--------------Save Initiated------------------'
	
	#Main plot save code
	size = (self.IntensityData[:,:,self.intensityindex].shape[0]*4, self.IntensityData[:,:,self.intensityindex].shape[1]*4)
	path = os.getenv('PWD')
	filenamelist = [path, '/', 'MainPlot_WaveLen', str(self.Wavelength).replace('.','_'), '.png']
	filename = ''.join(filenamelist)
	container = self.Main_img_plot
	temp = container.outer_bounds
	container.outer_bounds = list(size)
	container.do_layout(force=True)
	gc = PlotGraphicsContext(size, dpi=DPI)
	gc.render_component(container)
	gc.save(filename)
	container.outer_bounds = temp
	print "SAVED: ", filename
	
	#Spectra plot save code
	size = (1000,500)
	path = os.getenv('PWD')
	filenamelist = [path, '/', 'SpectraPlot_X', str(self.InspectorPosition[0]), '_Y', str(self.InspectorPosition[1]), '.png']
	filename = ''.join(filenamelist)
	container = self.Spectraplot1
	temp = container.outer_bounds
	container.outer_bounds = list(size)
	container.do_layout(force=True)
	gc = PlotGraphicsContext(size, dpi=DPI)
	gc.render_component(container)
	gc.save(filename)
	container.outer_bounds = temp
	print "SAVED: ", filename
	return
开发者ID:peterlandgren,项目名称:NCDF-Viewer,代码行数:36,代码来源:NCDFViewer.py

示例3: save_plot

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
def save_plot(plot, filename, width, height):
    plt_bounds = plot.outer_bounds
    plot.do_layout(force=True)
    gc = PlotGraphicsContext(plt_bounds, dpi=72)
    gc.render_component(plot)
    gc.save(filename)
    print "Plot saved to: ", filename
开发者ID:AttilaForgacs,项目名称:experimental,代码行数:9,代码来源:chaco_mpt_display.py

示例4: save_plot

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
def save_plot(plot, filename, width, height):
    # http://docs.enthought.com/chaco/user_manual/how_do_i.html
    from chaco.api import PlotGraphicsContext
    plot.outer_bounds = [width, height]
    plot.do_layout(force=True)
    gc = PlotGraphicsContext((width, height), dpi=72)
    gc.render_component(plot)
    gc.save(filename)
开发者ID:tkf,项目名称:mplchaco,代码行数:10,代码来源:demo.py

示例5: _save_raster

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
 def _save_raster(self):
     ''' Saves an image of the component.
     '''
     from chaco.api import PlotGraphicsContext
     gc = PlotGraphicsContext((int(self.component.outer_width), int(self.component.outer_height)))
     self.component.draw(gc, mode="normal")
     gc.save(self.filename)
     return
开发者ID:punchagan,项目名称:talks,代码行数:10,代码来源:animate.py

示例6: _save_plot

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
 def _save_plot(self, plot, filename, width=800, height=600, dpi=72):
     self.set_plot_title(plot, self.plot_title)
     original_outer_bounds = plot.outer_bounds
     plot.outer_bounds = [width, height]
     plot.do_layout(force=True)
     gc = PlotGraphicsContext((width, height), dpi=dpi)
     gc.render_component(plot)
     gc.save(filename)
     plot.outer_bounds = original_outer_bounds
开发者ID:magnunor,项目名称:analyzarr,代码行数:11,代码来源:save_plot.py

示例7: _save

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
    def _save(self):
        # Create a graphics context of the right size
        win_size = self.plot.outer_bounds
        plot_gc = PlotGraphicsContext(win_size)

        # Have the plot component into it
        plot_gc.render_component(self.plot)

        # Save out to the user supplied filename
        plot_gc.save(self._save_file)
开发者ID:enthought,项目名称:chaco,代码行数:12,代码来源:image_from_file.py

示例8: save_plot

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
 def save_plot(self, filename=None):
     ''' Saves an image of the component.
     '''
     if filename is None:
         filename = 'plots/plot%05d.jpg' %(round(self.time/self.delay*self.time_factor))
     d = os.path.dirname(filename)
     if d != '' and not os.path.exists(d):
         os.makedirs(os.path.dirname(filename))
     gc = PlotGraphicsContext((int(self.component.outer_width),
                 int(self.component.outer_height)))
     self.component.draw(gc, mode="normal")
     gc.save(filename)
开发者ID:punchagan,项目名称:talks,代码行数:14,代码来源:animate.py

示例9: save_raster

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
 def save_raster(self, filename):
     """
     Saves an image of a chaco component (e.g. 'Plot' or 'Container')
     to a raster file, such as .jpg or .png. The file type is terermined
     by the extension.
     """
     from chaco.api import PlotGraphicsContext
     gc = PlotGraphicsContext(self.outer_bounds, dpi=72)
     self.draw(gc, mode="normal")
     #gc.render_component(self)
     gc.save(filename)
     return
开发者ID:physikier,项目名称:magnetometer,代码行数:14,代码来源:chaco_addons.py

示例10: plotRU

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
    def plotRU(self,rangeX=None, rangeY=None, save=False, filename=""):
        if save and filename == "":
            self.add_line("ERROR: I need a valid file name")
            return

        if save and filename.split('.')[-1] != "png":
            self.add_line("ERROR: File must end in .png")
            return

        if len(self.morseList) > 0:
            plotData = ArrayPlotData(x=self.Rlist, y=self.Ulist, morse=self.morseList, eigX=[self.Rlist[0], self.Rlist[-1]])
        else:
            plotData = ArrayPlotData(x=self.Rlist, y=self.Ulist)


        for val in self.levelsToFind:
            if val < len(self.convergedValues):
                plotData.set_data("eig"+str(val), [self.convergedValues[val], self.convergedValues[val]])

        plot = Plot(plotData)

        if len(self.morseList) > 0:
            plot.plot(("x","morse"), type = "line", color = "red")

        for val in self.levelsToFind:
            if val < len(self.convergedValues):

                plot.plot(("eigX","eig"+str(val)), type="line", color="green")

        plot.plot(("x","y"), type = "line", color = "blue")
        plot.plot(("x","y"), type = "scatter", marker_size = 1.0, color = "blue")
        #
        plot.index_axis.title = "Separation (r0)"
        if (self.scaled):
            plot.value_axis.title = "Potential (Eh * 2 * mu)"
        else:
            plot.value_axis.title = "Potential (Eh)"

        if len(self.plotRangeX) != 0:
            plot.x_axis.mapper.range.low = self.plotRangeX[0]
            plot.x_axis.mapper.range.high = self.plotRangeX[1]
        if len(self.plotRangeY) != 0:
            plot.y_axis.mapper.range.low = self.plotRangeY[0]
            plot.y_axis.mapper.range.high = self.plotRangeY[1]
        if not save:
            self.plot = plot
        else:
            plot.outer_bounds = [800,600]
            plot.do_layout(force=True)
            gc = PlotGraphicsContext((800,600), dpi = 72)
            gc.render_component(plot)
            gc.save(filename)
开发者ID:BackgroundNose,项目名称:Vibromatic,代码行数:54,代码来源:quantumWobbler.py

示例11: on_savefig

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
    def on_savefig(self):
        """ Handles the user requesting that the image of the 
            function is to be saved.
        """
        import os
        dlg = FileDialog(parent=self.control,
                         title='Save as image',
                         default_directory=os.getcwd(),
                         default_filename="", wildcard=WILDCARD,
                         action='save as')
        if dlg.open() == OK:
            path = dlg.path

            print "Saving plot to", path, "..."
            try:

                """ Now we create a canvas of the appropriate size and 
                    ask it to render our component.  
                   (If we wanted to display this plot in a window, we
                    would not need to create the graphics context ourselves; 
                    it would be created for us by the window.)
                """
#                self._plot.bounds = [500,300]
#                self._plot.padding = 50
               # plot_gc = PlotGraphicsContext(self._plot.outer_bounds)
               # plot_gc.render_component(self._plot)

                #self._plot_container.outer_bounds = list((800,600))
#                plot_gc = PlotGraphicsContext((400,300), dpi=72.0)
#                plot_gc.render_component(self._plot_container)

                self.lplot.bounds = [500, 300]
                self.lplot.padding = 50

                win_size = self.lplot.outer_bounds
                plot_gc = PlotGraphicsContext(win_size)

                # Have the plot component into it
                plot_gc.render_component(self.lplot)

                # Finally, we tell the graphics context
                # to save itself to disk as an image.
                plot_gc.save(path)

            except:
                print "Error saving!"
                raise
            print "Plot saved."
        return
开发者ID:simvisage,项目名称:mxn,代码行数:51,代码来源:mfn_chaco_editor.py

示例12: draw_plot

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
def draw_plot(filename, size=(800,600), num_plots=8, type='line', key=''):
    """ Save the plot, and generate the hover_data file. """
    container = create_plot(num_plots, type)
    container.outer_bounds = list(size)
    container.do_layout(force=True)
    gc = PlotGraphicsContext(size, dpi=DPI)
    gc.render_component(container)
    if filename:
        gc.save(filename)
        script_filename = filename[:-4] + "_png_hover_data.js"
    else:
        script_filename = None
    plot = make_palettized_png_str(gc)
    script_data = write_hover_coords(container, key, script_filename)
    return (plot, script_data)
开发者ID:enthought,项目名称:chaco,代码行数:17,代码来源:javascript_hover_tools.py

示例13: _png_export_fired

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
    def _png_export_fired(self):
        outfileName = self._getFilePath(defFileName=self.__DEF_FILE_NAME + '.png')

        if outfileName != None:
            from chaco.api import PlotGraphicsContext
            container = self.plot
            tempSize = copy.deepcopy( container.outer_bounds )
            container.outer_bounds = list((self.width-1,self.height-1))
            container.do_layout(force=True)
            # gc = PlotGraphicsContext((self.width,self.height), dpi=self.dpi)
            gc = PlotGraphicsContext((self.width-1,self.height-1))
            gc.render_component(container)
            gc.save( outfileName )
            container.outer_bounds = tempSize
            self.plot.request_redraw()
开发者ID:kr2,项目名称:TouchIT-Log,代码行数:17,代码来源:Plot.py

示例14: _export_fired

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
    def _export_fired(self):
        dialog = FileDialog(action="save as", wildcard='.dat')
        dialog.open()
        if dialog.return_code == OK:
            # prepare plot for saving
            width = 800
            height = 600
            self.plot.outer_bounds = [width, height]
            self.plot.do_layout(force=True)
            gc = PlotGraphicsContext((width, height), dpi=72)
            gc.render_component(self.plot)

            #save data,image,description
            timetag = "" #init empty str for later
            directory = dialog.directory
            t = self.acqtime #retrieve time from last aquisition
            timelist = [t.tm_year,t.tm_mon,t.tm_mday,t.tm_hour,t.tm_min,t.tm_sec]
            timelist = map(str,timelist) #convert every entry to str of timelist
            for i in range(len(timelist)): #if sec is eg "5" change to "05"
                if len(timelist[i]) == 1:
                    timelist[i] = "0" + timelist[i]
            timetag = timetag.join(timelist) #make single str of all entries
            filename = timetag + dialog.filename # join timetag and inidivid. name
            print "target directory: " + directory
            gc.save(filename+".png")
            self.wvl = self.create_wavelength_for_plotting()
            x,y = self.icCryo.pos() #get cryo pos
            pos = "Cryo was at pos "+ str(x) + " x " + str(y)+" y"
            with open(filename+'.dat','wb') as f:
                f.write('#'+
                        str(pos)+
                        '\n'+
                        '#\n'+
                        '#\n'+
                        '#\n') #this is for the header
                np.savetxt(f,
                        np.transpose([self.wvl,self.line]),
                        delimiter='\t')
开发者ID:ottodietz,项目名称:qdsearch,代码行数:40,代码来源:camera.py

示例15: _save

# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import save [as 别名]
 def _save(self):
    win_size = self.plot.outer_bounds
    plot_gc = PlotGraphicsContext(win_size)#, dpi=300)
    plot_gc.render_component(self.plot)
    plot_gc.save("image_test.png")
开发者ID:thomasaref,项目名称:Side_project_software,代码行数:7,代码来源:Atom_Plotter2.py


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