gpt4 book ai didi

python - 如何用 Chaco 叠加两个图像?

转载 作者:太空宇宙 更新时间:2023-11-04 03:32:13 25 4
gpt4 key购买 nike

注意:我将亲自回答这个问题,以帮助将来遇到此问题的其他人。如果您愿意,请随时提交您自己的答案,但要知道已经有人回答了!

如何在 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

关于python - 如何用 Chaco 叠加两个图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30664506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com