python - Plot 3 figures with common colorbar by using Basemap -


i have been using code plot 3 figures common colorbar:

grid_top = imagegrid(fig, 211, nrows_ncols = (1, 3),                      cbar_location = "right",                           cbar_mode="single",                      cbar_pad=.2)   n in xrange(3):      im1 = grid_top[n].pcolor(data_top[n],                          interpolation='nearest', vmin=0, vmax=5)  plt.show() 

i want use basemap plot orthographic projection, define as:

m=basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l',           llcrnrx=0.,‌​llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.) 

when, change code above follow:

im1 = grid_top[n].m.pcolor(data_top[n], interpolation='nearest', vmin=0, vmax=5) 

i error..

what have change make works basemap ?

thank you

well, it's bit difficult diagnose specific error without seeing error message you're getting, i'll give go.

when call basemap() draws map active axes instance, when axes defined using imagegrid() , looped through none of them ever active. can activate existing axes instance @ time using plt.sca() (set current axes).

to finalise colorbar need call colorbar() instance after you've plotted data using pcolor() or imshow().

here's working example of think you're trying achieve:

data_top = [] in range(3):     data_top.append(np.random.random((5,5)))   fig = plt.figure(1,(8.,8.))  grid_top = imagegrid(fig, 211, nrows_ncols = (1, 3),                      cbar_location = "right",                      cbar_mode="single",                      cbar_pad=.2)  g, d in zip(grid_top,data_top):     plt.sca(g)     m = basemap(projection='ortho',lon_0=10.0,lat_0=50.0,resolution='l')     m.drawcoastlines()     m.drawparallels(np.arange(-90.,120.,30.))     m.drawmeridians(np.arange(0.,360.,60.))     = m.imshow(d,vmin=0,vmax=1,interpolation="nearest") grid_top.cbar_axes[0].colorbar(i) 

some ugly maps, idea.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -