本文整理汇总了Python中chaco.api.HPlotContainer.invalidate_draw方法的典型用法代码示例。如果您正苦于以下问题:Python HPlotContainer.invalidate_draw方法的具体用法?Python HPlotContainer.invalidate_draw怎么用?Python HPlotContainer.invalidate_draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chaco.api.HPlotContainer
的用法示例。
在下文中一共展示了HPlotContainer.invalidate_draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlotUI
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import invalidate_draw [as 别名]
#.........这里部分代码省略.........
self.cross_plot.index_range = self.polyplot.index_range.x_range
self.pd.set_data("line_index2", array([]))
self.pd.set_data("line_value2", array([]))
self.pd.set_data("scatter_index2", array([]))
self.pd.set_data("scatter_value2", array([]))
self.pd.set_data("scatter_color2", array([]))
self.cross_plot2 = Plot(self.pd, width = 140, orientation="v",
resizable="v", padding=20, padding_bottom=160)
self.cross_plot2.plot(("line_index2", "line_value2"),
line_style="dot")
self.cross_plot2.plot(("scatter_index2",
"scatter_value2",
"scatter_color2"),
type="cmap_scatter",
name="dot",
color_mapper=self._cmap(image_value_range),
marker="circle",
marker_size=8)
self.cross_plot2.index_range = self.polyplot.index_range.y_range
# Create a container and add components
self.container = HPlotContainer(padding=40, fill_padding=True,
bgcolor = "white", use_backbuffer=False)
inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
inner_cont.add(self.cross_plot)
inner_cont.add(contour_container)
self.container.add(self.colorbar)
self.container.add(inner_cont)
self.container.add(self.cross_plot2)
def update(self, model):
self.minz = model.minz
self.maxz = model.maxz
self.colorbar.index_mapper.range.low = self.minz
self.colorbar.index_mapper.range.high = self.maxz
self._image_index.set_data(model.xs, model.ys)
self._image_value.data = model.zs
self.pd.update_data(line_index=model.xs, line_index2=model.ys)
self.container.invalidate_draw()
self.container.request_redraw()
#---------------------------------------------------------------------------
# Event handlers
#---------------------------------------------------------------------------
def _metadata_changed(self, old, new):
""" This function takes out a cross section from the image data, based
on the line inspector selections, and updates the line and scatter
plots."""
self.cross_plot.value_range.low = self.minz
self.cross_plot.value_range.high = self.maxz
self.cross_plot2.value_range.low = self.minz
self.cross_plot2.value_range.high = self.maxz
if self._image_index.metadata.has_key("selections"):
x_ndx, y_ndx = self._image_index.metadata["selections"]
if y_ndx and x_ndx:
xdata, ydata = self._image_index.get_data()
xdata, ydata = xdata.get_data(), ydata.get_data()
self.pd.update_data(
line_value=self._image_value.data[y_ndx,:],
line_value2=self._image_value.data[:,x_ndx],
scatter_index=array([xdata[x_ndx]]),
scatter_index2=array([ydata[y_ndx]]),
scatter_value=array([self._image_value.data[y_ndx, x_ndx]]),
scatter_value2=array([self._image_value.data[y_ndx, x_ndx]]),
scatter_color=array([self._image_value.data[y_ndx, x_ndx]]),
scatter_color2=array([self._image_value.data[y_ndx, x_ndx]])
)
else:
self.pd.update_data({"scatter_value": array([]),
"scatter_value2": array([]), "line_value": array([]),
"line_value2": array([])})
def _colormap_changed(self):
self._cmap = default_colormaps.color_map_name_dict[self.colormap]
if self.polyplot is not None:
value_range = self.polyplot.color_mapper.range
self.polyplot.color_mapper = self._cmap(value_range)
value_range = self.cross_plot.color_mapper.range
self.cross_plot.color_mapper = self._cmap(value_range)
# FIXME: change when we decide how best to update plots using
# the shared colormap in plot object
self.cross_plot.plots["dot"
][0].color_mapper = self._cmap(value_range)
self.cross_plot2.plots["dot"
][0].color_mapper = self._cmap(value_range)
self.container.request_redraw()
def _num_levels_changed(self):
if self.num_levels > 3:
self.polyplot.levels = self.num_levels
self.lineplot.levels = self.num_levels
示例2: ImageGUI
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import invalidate_draw [as 别名]
#.........这里部分代码省略.........
self.cross_plot2.index_range = self.imgplot.index_range.y_range
# Create a container and add sub-containers and components
self.column_density = HPlotContainer(padding=40, fill_padding=True,
bgcolor = "white", use_backbuffer=False)
inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
inner_cont.add(self.cross_plot)
self.imgplot.padding =20
inner_cont.add(self.imgplot)
self.column_density.add(self.colorbar)
self.column_density.add(inner_cont)
self.column_density.add(self.cross_plot2)
def update(self):
#print self.cursor.current_index
#self.cursor.current_position = 100.,100.
self.shots = self.populate_shot_list()
print self.selectedshot
imgdata, self.report = self.load_imagedata()
if imgdata is not None:
self.minz = imgdata.min()
self.maxz = imgdata.max()
self.colorbar.index_mapper.range.low = self.minz
self.colorbar.index_mapper.range.high = self.maxz
xs=numpy.linspace(0,imgdata.shape[0],imgdata.shape[0]+1)
ys=numpy.linspace(0,imgdata.shape[1],imgdata.shape[1]+1)
#print xs
#print ys
self._image_index.set_data(xs,ys)
self._image_value.data = imgdata
self.pd.set_data("line_index", xs)
self.pd.set_data("line_index2",ys)
self.column_density.invalidate_draw()
self.column_density.request_redraw()
def populate_shot_list(self):
try:
shot_list = os.listdir(self.shotdir)
fun = lambda x: iscol(x,self.namefilter)
shot_list = filter( fun, shot_list)
shot_list = sorted(shot_list)
except ValueError:
print " *** Not a valid directory path ***"
return shot_list
def load_imagedata(self):
try:
directory = self.shotdir
if self.selectedshot == []:
filename = self.shots[0]
else:
filename = self.selectedshot[0]
#shotnum = filename[filename.rindex('_')+1:filename.rindex('.ascii')]
shotnum = filename[:filename.index('_')]
except ValueError:
print " *** Not a valid path *** "
return None
# Set data path
# Prepare PlotData object
print "Loading file #%s from %s" % (filename,directory)
return import_data.load(directory,filename), import_data.load_report(directory,shotnum)
#---------------------------------------------------------------------------
# Event handlers
示例3: ImageGUI
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import invalidate_draw [as 别名]
#.........这里部分代码省略.........
type="cmap_scatter",
name="dot",
color_mapper=self._cmap(image_value_range),
marker="circle",
marker_size=8,
)
self.cross_plot2.index_range = self.imgplot.index_range.y_range
# Create a container and add components
self.container = HPlotContainer(padding=40, fill_padding=True, bgcolor="white", use_backbuffer=False)
inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
inner_cont.add(self.cross_plot)
inner_cont.add(contour_container)
self.container.add(self.colorbar)
self.container.add(inner_cont)
self.container.add(self.cross_plot2)
def update(self):
imgdata = self.load_imagedata()
if imgdata is not None:
self.minz = imgdata.min()
self.maxz = imgdata.max()
self.colorbar.index_mapper.range.low = self.minz
self.colorbar.index_mapper.range.high = self.maxz
xs = numpy.linspace(0, imgdata.shape[0], imgdata.shape[0] + 1)
ys = numpy.linspace(0, imgdata.shape[1], imgdata.shape[1] + 1)
print xs
print ys
self._image_index.set_data(xs, ys)
self._image_value.data = imgdata
self.pd.set_data("line_index", xs)
self.pd.set_data("line_index2", ys)
self.container.invalidate_draw()
self.container.request_redraw()
def load_imagedata(self):
try:
dir = self.shot[self.shot.index(":\\") + 2 : self.shot.rindex("\\") + 1]
shotnum = self.shot[self.shot.rindex("_") + 1 : self.shot.rindex(".ascii")]
except ValueError:
print " *** Not a valid column density path *** "
return None
# Set data path
# Prepare PlotData object
print dir
print shotnum
return load(dir, shotnum)
# ---------------------------------------------------------------------------
# Event handlers
# ---------------------------------------------------------------------------
def _shot_changed(self):
self.update()
def _metadata_changed(self, old, new):
""" This function takes out a cross section from the image data, based
on the line inspector selections, and updates the line and scatter
plots."""
self.cross_plot.value_range.low = self.minz
self.cross_plot.value_range.high = self.maxz
self.cross_plot2.value_range.low = self.minz
self.cross_plot2.value_range.high = self.maxz
if self._image_index.metadata.has_key("selections"):