Problem solved thanks to Jose.

For interest...

import numpy as np
import matplotlib.pyplot as plt
a = np.array([[1,2,3,np.nan,5],[4,22,np.nan,11,9]])
palette = plt.cm.jet
palette.set_bad ('w',1.0) # Bad values (i.e., masked, set to grey 0.8
A = np.ma.array ( a, mask=np.isnan(a))
plt.imshow(A,interpolation='nearest',cmap=palette)
plt.show()



mdekauwe wrote:
> 
> Hi,
> 
> I am trying to plot a 2D array which contains some NaN values as a map. I
> would like to be able to control the colours assigned to these data
> points. At the moment it seems that there are given the same colour as the
> highest value in the array. Any suggestions would be appreciated. Although
> not using the basemap I think this example highlights my issue
> 
> import numpy as np
> import matplotlib.pyplot as plt
> a = np.array([[1,2,3,np.nan,5],[4,22,np.nan,11,9]])
> plt.imshow(a)
> plt.show()
> 
> as you can hopefully see the NaNs are given the same colours as the
> highest values in the array. Ideally I would like to give these the colour
> white, regardless of what colourmap is later applied with basemap.
> 
> Many thanks
> 
> Martin
> 

-- 
View this message in context: 
http://www.nabble.com/Controlling-colours-for-NaN-values-with-basemap-tp25609596p25612886.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to