Closed neurosignal closed 2 years ago
Hey @neurosignal . I edited your description to fix the code formatting. I hope that's okay.
There used to be a VTK backend for Enable (and hence Chaco), but it was not well-supported and so was removed for Enable 5. It was not particularly sophisticated: it just rendered the Chaco plot into a bitmap and then displayed it in the VTK scene, but it might be a starting point for what you need.
The code can be found here: https://github.com/enthought/enable/tree/4.8.1/enable/vtk_backend
ETA: this may not match your need - this was overlaying the chaco plot on top of the Mayavi scene.
Actually, looking a bit closer the problem you have is more fundamental: you are not creating your Chaco Plot
correctly. Chaco and Mayavi have different internal models, and so your Chaco plot is completely independent of the Mayavi plot. In particular, this code is returning a Mayavi object, not a Chaco Plot
, so it will fail:
self.plot = self.scene.mlab.points3d(x, y, z, color=(1,0.5,0.5))
You need to do something like:
def __init__(self):
...
plot_data = ArrayPlotData(x=self.points[:, 0], y=self.points[:, 1], z=self.points[:, 2])
plot = Plot(plot_data)
plot.plot(['x', 'y'], 'scatter')
self.chaco_plot = plot
and
@observe('points')
def update_points(self, event):
self.chaco_plot.data.update(x=self.points[:, 0], y=self.points[:, 1], z=self.points[:, 2])
and
Item('chaco_plot', editor=ComponentEditor(), show_label=True)
or something similar, following standard Chaco conventions.
You will still need something like your existing code, but the plot
there is a Mayavi plot, and it probably makes sense to call it that.
Thank you very much @rahulporuri for fixing it.
Thanks a lot, @corranwebster. It helped very much and now it's working after integrating your suggestions.
Hi, I am trying to integrate a mayavi scene and a Chaco plot in the same Traits-based user interface, but I am getting errors. I tried to explore the tutorials and examples but did not find any. Is it possible at all or not, is there any link explaining such a case? Thanks in advance. Below is the code snippet where I am defining my View
The complete code: