[Numpy-discussion] numpy, matplotlib and masked arrays

Peter Isaac Peter.Isaac@monash....
Fri Jul 9 20:03:47 CDT 2010


hello fellow numpyneers,

I'm not sure if this is a problem with numpy, matplotlib, EPD or me but
here goes.  The general problem is that either matplotlib has stopped
plotting masked arrays correctly or numpy has changed the way masked
arrays are presented.  Or there is something strange with the Enthought
Python Distribution or me.  Many would agree with the latter ...

First up, the platform:
Linux pisaac-laptop 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 07:54:58
UTC 2010 i686 GNU/Linux

Next the symptom:
matplotlib stops plotting masked array values at the first occurrence of
a True mask value.

Then the script:
from matplotlib import pyplot
import numpy
a = numpy.array(range(0,100))
a[50] = -9999.0
b = numpy.ma.masked_where(a==-9999,a)
pyplot.subplot(211)
pyplot.plot(a)
pyplot.subplot(212)
pyplot.plot(b)
pyplot.show()

Now the twists:
The above script works correctly with the Python installation from the
Ubuntu repositories (10.04 LTS).  Details of the installation are:
Python V2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
matplotlib '0.99.1.1'
numpy '1.3.0'

The above script does not work correctly in either EPD-6.1-1 or
EPD-6.2-2.  Their details are:
EPD-6.1-1
Python 2.6.4 |EPD 6.1-1 (32-bit)| (r264:75706, Nov  4 2009, 15:27:32)
matplotlib '0.99.1.1'
numpy '1.4.0'

EPD-6.2-2
Python 2.6.5 |EPD 6.2-2 (32-bit)| (r265:79063, Mar 22 2010, 17:31:34)
matplotlib '0.99.3'
numpy '1.4.0'

Since the matplotlib version is the same for the repository Python
installation and the EPD-6.1-1 installation and the script works in the
first but not the second, it suggests the problem is not just
matplotlib.  That seems to leave the numpy version change (from 1.3 to
1.4) or something in the EPD.  Or me.  Note that EPD-6.2-2 works fine
with this script on WinXP.

Any suggestions welcome and happy to supply further details if required.

Yours in masked confusion,
Peter




More information about the NumPy-Discussion mailing list