注意:我将亲自回答这个问题,以帮助将来遇到此问题的其他人。如果您愿意,请随时提交您自己的答案,但要知道已经有人回答了!
如何在 Chaco 中将具有一个颜色图的蒙版图像叠加到另一个具有不同颜色图的图像上?另外,如何为其中的每一个添加颜色条?
请您参考如下方法:
我并不是 100% 相信这一点,通过在线快速搜索我发现您可以使用以下代码进行简单的叠加:
来源来源:
http://docs.enthought.com/chaco/user_manual/containers.html#overlayplotcontainer
引用代码:
class OverlayImageExample(HasTraits):
plot = Instance(OverlayImage)
traits_view = View(
Item('plot', editor=ComponentEditor(), show_label=False),
width=800, height=600, resizable=True
)
def _plot_default(self):
# Create data
x = linspace(-5, 15.0, 100)
y = jn(3, x)
pd = ArrayPlotData(index=x, value=y)
zoomable_plot = Plot(pd)
zoomable_plot.plot(('index', 'value'),
name='external', color='red', line_width=3)
# Attach tools to the plot
zoom = ZoomTool(component=zoomable_plot,
tool_mode="box", always_on=False)
zoomable_plot.overlays.append(zoom)
zoomable_plot.tools.append(PanTool(zoomable_plot))
# Create a second inset plot, not resizable, not zoom-able
inset_plot = Plot(pd)
inset_plot.plot(('index', 'value'), color='blue')
inset_plot.set(resizable = '',
bounds = [250, 150],
position = [450, 350],
border_visible = True
)
# Create a container and add our plots
container = OverlayPlotContainer()
container.add(zoomable_plot)
container.add(inset_plot)
return container
