16 Jul 2012 09:18
AbstractDataSource and AbstractPlotData
Hello,
In the absence of detailed documentation, I was wondering if someone
could help me understand the difference between AbstractDataSource and
AbstractPlotData. If I understand correctly, AbstractDataSource (and
classes that inherit it) is used to wrap data that is going to be
handled by a plot, but from the little documentation for
AbstractPlotData, it also seems to serve the same purpose although it's
used in a different way, and seems to lack metadata. When should one or
the other be used?
Take an example. I am plotting a 2D array representing an image. From
Chaco's examples this seems to be accomplished with:
pd = ArrayPlotData()
pd.set_data("imagedata", my_array)
plot = Plot(pd)
plot.img_plot("imagedata")
(ArrayPlotData being derived from AbstractPlotData)
However, some other examples with contourmaps seem to use the following
approach:
image_index = GridDataSource(my_array1, my_array2)
image_value = ImageData(data=my_array)
CMapImagePlot(index = image_index, value = image_value)
(GridDataSource and ImageData being derived from AbstractDataSource.)
Both of this approaches produce a colormapped image, but one makes use
of AbstractDataSource and AbstractPlotData. When should either be used?
I note that AbstractDataSource has the advantange of saving the
metadata, which in 'selections' has information from tools such as mouse
position and selections. (I also understand that my second example can
be used for irregular grids.)
Also, if using the ArrayPlotData path, and building some tool from
BaseTool, is there any communication method between the tool and the
plot (similar to metadata in ImageData)? I saw the example tool that
prints event.x and event.y on normal_mouse_move, but did not see an
obvious communication if I want to use these values from the plot itself
(or a class calling the plot).
Thanks again,
Tiago
RSS Feed