plot with nans

Alan,

But I still feel something is missing from this discussion. Would it be odd/hard for plot() to have an option that says, effectively, mask NaNs so that the expected behavior results?

Again, the problem is that automatic masking of nans would be easy with numarray but not at all easy with Numeric. Given that mpl is designed to work the same with numarray and Numeric, it is not easy to build good nan support into mpl. This will change when the successor to Numeric becomes common enough that support for old Numeric can be dropped, but not soon. In the meantime, if you want to use nans, you can do something like this:

>>> import numarray as N
>>> from numarray.ieeespecial import isnan, nan
>>> import numarray.ma as ma
>>> a = N.array([1, 2, nan, 3, 4])
>>> b = ma.masked_where(isnan(a), a)

Now you can plot b and it will have a gap in the middle.

Eric

Thanks.
Alan

···

On Tue, 12 Jul 2005, Eric Firing apparently wrote:

import numarray as N
from numarray.ieeespecial import isnan, nan
import numarray.ma as ma
a = N.array([1, 2, nan, 3, 4])
b = ma.masked_where(isnan(a), a)

Now you can plot b and it will have a gap in the middle.

Hi Eric,

Eric Firing wrote:

Again, the problem is that automatic masking of nans would be easy with numarray but not at all easy with Numeric. Given that mpl is designed to work the same with numarray and Numeric, it is not easy to build good nan support into mpl. This will change when the successor to Numeric becomes common enough that support for old Numeric can be dropped, but not soon. In the meantime, if you want to use nans, you can do something like this:

>>> import numarray as N
>>> from numarray.ieeespecial import isnan, nan
>>> import numarray.ma as ma
>>> a = N.array([1, 2, nan, 3, 4])
>>> b = ma.masked_where(isnan(a), a)

Now you can plot b and it will have a gap in the middle.

I tried it as described above but plotting with pylab.plot results in an error
message:

MAError: Cannot automatically convert masked array to Numeric because data
                    is masked in one or more locations.

Am I missing something?

Regards, Christian