1

I am drawing some maps of accumulated rain, but they have different color scale and such I can't compare the displayed maps. There is some way for to obtain the maps with same color scale. Below is my code.

def plotea_fig(map,tite): 
    fig = pl.figure(figsize=(8,6), edgecolor='W',facecolor='W')
    m = Basemap(projection='merc', llcrnrlat=-5.125, urcrnrlat=14.125, llcrnrlon=-80.125, urcrnrlon=-65.5, resolution='i')
    m.drawcoastlines(linewidth = 0.8)
    m.drawstates(linewidth = 0.3)
    m.drawcountries(linewidth = 0.8)
    m.drawparallels(np.arange(-5, 14.9583, 5),labels=[1,0,0,1])
    m.drawmeridians(np.arange(-170,-60,5),labels=[1,0,0,1])
    x,y = m(lons,lats)
    CS1 = m.contourf(x,y,map, 35, cmap=pl.cm.jet_r, animated=True) 
    cb = m.colorbar(CS1, size="5%", pad="2%")
    cb.ax.tick_params(labelsize=20) 
    pl.xlabel('LONGITUDE')
    pl.ylabel('LATITUD')
    pl.title(title) 
    pl.savefig(title,bbox_inches='tight', formart = 'png')

    return m
Yordan A
  • 13
  • 2

1 Answers1

2

Rather than simply saying you want 35 contours, you should specify which contours you want to plot. For example:

m.contourf(x, y, map, np.linspace(5, 10, 35), extend='both',
           cmap=pl.cm.jet_r, animated=True)

This specifies that you want 35 contours between values of 5 and 10. The extend='both' kwarg indicates that data above/below 5/10 should be colored with the top/bottom color. This will add 'pointy ends' to your colorbar, which some people don't like, but others feel is more explicit. Take a look at my answer to this question for more details.

Community
  • 1
  • 1
farenorth
  • 10,165
  • 2
  • 39
  • 45