Feed on

to give NaNs their own specific color in a plot, use a masked array.  for example, the code below will color NaNs white:

import numpy.ma
import pylab as pl
masked_X = numpy.ma.array(X,mask=np.isnan(X))
fig, ax = pl.subplots(1)
im1 = ax.matshow(masked_X)

Bookmark and Share

if that was helpful ...

check out the other tips and tricks i've compiled on these pages. you might learn something else interesting!

Did I get this wrong? Let me know!

Trackback URI | Comments RSS