Christian Meesters wrote: > Hi, > > I have a 2D masked array, created like: > > import numpy as np > data = np.ma.array(data, mask=[data == 'NA']) > > which I would like to plot as a heatmap. > > import pylab > > pylab.pcolor(data) > or > pylab.pcolormesh(data) > > Well, it works with any array, but not if masked values are in there. > Can somebody supply me with a snippet, as I apparently don't get the > relevant piece in the docs (or did not find it ;-) ). > > TIA > Christian > >
Christian: That should work, if you created the masked array correctly. Why are you creating the mask with data=='NA'? I suspect that this always evaluates to False, so you don't get a mask. You probably want to check for a numeric value, not a string. For example: import matplotlib.pyplot as plt import numpy as np def func3(x,y): return (1- x/2 + x**5 + y**3)*np.exp(-x**2-y**2) dx, dy = 0.05, 0.05 x = np.arange(-3.0, 3.0001, dx) y = np.arange(-3.0, 3.0001, dy) X,Y = np.meshgrid(x, y) Z = func3(X, Y) Z = np.ma.array(Z, mask=Z>0.5) plt.pcolor(Z) plt.show() -Jeff ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users