Attached are a slightly modified lines.py, based on CVS download this morning, and a demo of plotting masked arrays.
The changes to lines.py are:
1) additional function imports from numerix
2) importing numerix.ma
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 lines.py. 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 lines.py 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 contour.py 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.
masked_line_demo.py (606 Bytes)
lines.py (38.4 KB)