Matplotlib error with colormap in version 1.5.0
Question: In a python script, I just upgraded my matplotlib to 1.5.0 and am now getting
this error:

    
    
    from matplotlib import pyplot as plt
    import matplotlib.ticker as tkr
    from matplotlib import rcParams
    from mpl_toolkits.basemap import Basemap, maskoceans
        cs = m.contourf(x,y,mask_data,numpy.arange(min_range,max_range,step),cmap=PRGn_10.mpl_colormap)
    NameError: global name 'PRGn_10' is not defined
    

How can I fix this?


Answer: It is not a `matplotlib` error. The error message says that the name `PRGn_10`
is not defined — because you never defined it. It is not present in any of
your imports, and it is not a built-in, so Python cannot find it.

I am guessing you wanted to use the `PRGn` colormap. In order to do so, you
need to import it, or the whole `colormap` module and reference it properly:

    
    
    import matplotlib.cm as cm
    cs = m.contourf(x,y,mask_data,numpy.arange(min_range,max_range,step),cmap=cm.PRGn)
    

or

    
    
    from matplotlib.cm import PRGn
    cs = m.contourf(x,y,mask_data,numpy.arange(min_range,max_range,step),cmap=PRGn)
    

Not sure what you meant by the `.mpl_colormap` bit, colormaps do not have such
attribute.

