Chaco colormap from structured and irregular grid

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Chaco colormap from structured and irregular grid

Tiago Pereira
Hi all,

I'm trying to plot a colormap from a 2D array. Both x and y scales are
irregularly spaced. Using CmapImagePlot I though I almost had it, but
then realised that the plot actually assumed constant spacing between
grid points. Here's what I've done (simplified):

# xs, ys, z = my data points, x and y 1-D arrays and z 2D array

image_index = GridDataSource(xdata=xs, ydata=ys)
index_mapper = GridMapper(range=DataRange2D(image_index))

color_source = ImageData(data=z, value_depth=1)
color_mapper = jet(DataRange1D(color_source))

CMapImagePlot(index=image_index, index_mapper=index_mapper,
               value=color_source, value_mapper=color_mapper)


However, despite supplying the grid points to GridDataSource, the plot
still comes out as constant spaced grid points. Digging a bit deeper I
see that GridMapper is actually using a linear _xmapper and _ymapper
(the only options seem to be linear or log). So are xdata and ydata in
GridDataSource only used to set the bounds? (The rest of the values seem
to be ignored.)

Is it possible to build another _xmapper and _ymapper from Base1DMapper
for irregular grids? Has anyone done it? From a quick inspection of
LinearMapper and LogMapper it seems like one would need an analytical
expression for the grid spacing (which I don't have).

Is there any other way to plot a colormap for an irregularly spaced
array (as in matplotlib's pcolormesh)? (I know there have been a few
questions about this, but they went mostly unanswered.)

Thanks,

Tiago
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev