plotting masked data


Attached are a slightly modified, based on CVS download this morning, and a demo of plotting masked arrays.

The changes to are:

1) additional function imports from numerix
2) importing
3) a new function at the top of the file, unmasked_index_ranges.
4) changes to the draw and set_data methods
5) docstring indentation

I think that with these fairly small changes, the plot command (or anything that uses Line2D to make lines or sets of markers) will work exactly the same as before with unmasked data, and will work correctly with masked data. That is, only the valid points will be plotted, and lines will be broken at gaps.

I went for the simplest and least-intrusive changes I could find; maybe drawing the line segments could be improved by using the line collection renderer instead of a loop over ordinary line segments. It could also be optimized by not plotting line segments (as opposed to markers) when there is only one point. Let me know if you want me to look into any of these things; for now, I just wanted to get something working.

The unmasked_index_ranges function, or some variation of it, might be useful outside There are many ways it could be altered. I chose the 2-D array return, as opposed to a sequence of tuples, or a pair of 1-D arrays, in the hopes that it would be clear, efficient, and flexible; for example, it makes calculation of line segment lengths doable with a single "diff".

In lines 263,264 of I put a question, not directly relevant to the changes I made, but pointing to what may be a minor oversight.

I hope I haven't overlooked anything major!

If all this is going in the right direction, I will add masked array support to later this week. It should be trivial. I would then be inclined to remove the "experimental" kwarg, badmask.

Finding the bug in filled contours with masking remains to be done.

Eric (606 Bytes) (38.4 KB)