本文整理汇总了Python中chaco.api.PlotGraphicsContext.render_component方法的典型用法代码示例。如果您正苦于以下问题:Python PlotGraphicsContext.render_component方法的具体用法?Python PlotGraphicsContext.render_component怎么用?Python PlotGraphicsContext.render_component使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chaco.api.PlotGraphicsContext
的用法示例。
在下文中一共展示了PlotGraphicsContext.render_component方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_plot
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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
示例2: _SaveFlag_changed
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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
示例3: save_plot
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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)
示例4: test_scatter_1d_selection
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [as 别名]
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))
示例5: _save_plot
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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
示例6: _save
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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)
示例7: test_scatter_1d
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [as 别名]
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))
示例8: test_scatter_1d_selection_mask_name
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [as 别名]
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))
示例9: test_scatter_fast
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [as 别名]
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))
示例10: plotRU
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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)
示例11: test_scatter_circle
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [as 别名]
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))
示例12: test_scatter_1d_horizontal_flipped
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [as 别名]
def test_scatter_1d_horizontal_flipped(self):
self.scatterplot.direction = 'flipped'
self.scatterplot.orientation = 'h'
self.assertEqual(self.scatterplot.origin, 'bottom right')
self.assertEqual(self.scatterplot.x_mapper,
self.scatterplot.index_mapper)
self.assertIsNone(self.scatterplot.y_mapper)
gc = PlotGraphicsContext(self.size)
gc.render_component(self.scatterplot)
actual = gc.bmp_array[:, :, :]
self.assertFalse(alltrue(actual == 255))
示例13: test_scatter_1d_custom
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [as 别名]
def test_scatter_1d_custom(self):
path = CompiledPath()
path.move_to(-5, -5)
path.line_to(5, 5)
path.line_to(5, -5)
path.line_to(-5, 5)
path.line_to(-5, -5)
self.scatterplot.marker = 'custom'
self.scatterplot.custom_symbol = path
gc = PlotGraphicsContext(self.size)
gc.render_component(self.scatterplot)
actual = gc.bmp_array[:, :, :]
self.assertFalse(alltrue(actual == 255))
示例14: on_savefig
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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
示例15: draw_plot
# 需要导入模块: from chaco.api import PlotGraphicsContext [as 别名]
# 或者: from chaco.api.PlotGraphicsContext import render_component [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)