I have an HPlotContainer with 2 empty LinePlots as defaults, created using create_line_plot() factory function. I then perform some calculations and would like to update the plots. How do I access the ArrayPlotData of a LinePlot? I have tried something like container.components[0].data and I got an
AttributeError: 'LinePlot' object has no attribute 'data'
Clearly I am not doing the right thing here.
The
LinePlotobject you are manipulating is actually what Chaco calls a "renderer" and doesn't have access to the data. To update the plots dynamically, you want to call theset_datamethod on theArrayPlotDataobject. You can access that on thePlotobjects, but in your case it makes most sense to keep a reference directly to theArrayPlotDataobject. If you want to update theLinePlotobject then make a reference to it. This example shows the standard way to do that kind of thing with TraitsUI and Chaco:Now you can do whatever manipulations you want on the
LinePlotobject.I get output that looks like this: