本文整理汇总了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
示例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
示例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
示例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
示例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)
示例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))
示例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
示例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))
示例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)
示例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))
示例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))
示例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)
示例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
示例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)
示例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))