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


Python api.PlotGraphicsContext类代码示例

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


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

示例1: OnMenuExportPNG

    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,代码行数:31,代码来源:frontend.py

示例2: _SaveFlag_changed

    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,代码行数:34,代码来源:NCDFViewer.py

示例3: save_plot

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,代码行数:7,代码来源:chaco_mpt_display.py

示例4: _save_raster

 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,代码行数:8,代码来源:animate.py

示例5: save_plot

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,代码行数:8,代码来源:demo.py

示例6: test_scatter_1d_selection

    def test_scatter_1d_selection(self):
        self.scatterplot.index.metadata['selections'] = [
            (arange(10) % 2 == 0),
        ]

        gc = PlotGraphicsContext(self.size)
        gc.render_component(self.scatterplot)
        actual = gc.bmp_array[:, :, :]
        self.assertFalse(alltrue(actual == 255))
开发者ID:binaryannamolly,项目名称:chaco,代码行数:9,代码来源:line_scatterplot_test_case.py

示例7: _save_plot

 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,代码行数:9,代码来源:save_plot.py

示例8: test_scatter_1d

    def test_scatter_1d(self):
        self.assertEqual(self.scatterplot.origin, 'bottom left')
        self.assertIsNone(self.scatterplot.x_mapper)
        self.assertEqual(self.scatterplot.y_mapper,
                         self.scatterplot.index_mapper)

        gc = PlotGraphicsContext(self.size)
        gc.render_component(self.scatterplot)
        actual = gc.bmp_array[:, :, :]
        self.assertFalse(alltrue(actual == 255))
开发者ID:enthought,项目名称:chaco,代码行数:10,代码来源:text_plot_1d_test_case.py

示例9: _save

    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,代码行数:10,代码来源:image_from_file.py

示例10: test_scatter_1d_selection_mask_name

    def test_scatter_1d_selection_mask_name(self):
        # select with a mask
        self.scatterplot.selection_metadata_name = 'highlight_masks'
        self.scatterplot.index.metadata['highlight_masks'] = [
            (arange(10) % 2 == 0),
        ]

        gc = PlotGraphicsContext(self.size)
        gc.render_component(self.scatterplot)
        actual = gc.bmp_array[:, :, :]
        self.assertFalse(alltrue(actual == 255))
开发者ID:binaryannamolly,项目名称:chaco,代码行数:11,代码来源:line_scatterplot_test_case.py

示例11: test_scatter_fast

 def test_scatter_fast(self):
     """ Coverage test to check basic case works """
     size = (50, 50)
     scatterplot = create_scatter_plot(
         data=[range(10), range(10)],
         border_visible=False,
     )
     scatterplot.outer_bounds = list(size)
     gc = PlotGraphicsContext(size)
     gc.render_component(scatterplot)
     actual = gc.bmp_array[:, :, :]
     self.assertFalse(alltrue(actual == 255))
开发者ID:SDiot,项目名称:chaco,代码行数:12,代码来源:scatterplot_renderers_test_case.py

示例12: save_plot

 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,代码行数:12,代码来源:animate.py

示例13: save_raster

 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,代码行数:12,代码来源:chaco_addons.py

示例14: plotRU

    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,代码行数:52,代码来源:quantumWobbler.py

示例15: test_scatter_circle

 def test_scatter_circle(self):
     """ Coverage test to check circles work """
     size = (50, 50)
     scatterplot = create_scatter_plot(
         data=[list(sm.xrange(10)), list(sm.xrange(10))],
         marker="circle",
         border_visible=False,
     )
     scatterplot.outer_bounds = list(size)
     gc = PlotGraphicsContext(size)
     gc.render_component(scatterplot)
     actual = gc.bmp_array[:, :, :]
     self.assertFalse(alltrue(actual == 255))
开发者ID:enthought,项目名称:chaco,代码行数:13,代码来源:scatterplot_renderers_test_case.py


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