awulll
awulll

Reputation: 161

Basemap: create figure with graph and map

I'm creating a map with basemap and would like to put a graph in the same figure. Until now I did this:

m = Basemap(projection='merc',llcrnrlat=-32.5,urcrnrlat=-10,llcrnrlon=-57.5,urcrnrlon=-40,lat_ts=20,resolution='c')
x, y = m(lon, lat) # compute map proj coordinates.
parallels = np.arange(-50.,20,5.)
meridians = np.arange(-90.,0.,5.)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
m.scatter(x,y,s=abs(100.*np.array(correlacoes[i])),c=correlacoes[i],norm=mc.Normalize(vmin=-1.0,vmax=1.0))
m.drawcoastlines()
m.colorbar()
pyl.title(nomvar + ' cp ' + str(i+1) + '   v.e. %5.2f' % varexp[i])
pyl.savefig(dir_pro+projeto+arquivo + '_cp%3.3i' % (i+1) + '.png')   
pyl.clf()    
pyl.plot(indicesfs,fs[i])
pyl.title(nomvar + ' cp ' + str(i+1) + '   v.e. %5.2f' % varexp[i])
pyl.savefig(dir_pro+projeto+arquivo + '_fs%3.3i' % (i+1) + '.png')   
pyl.clf()

But in this way I have two figures, and I would like to put both (graph and map) in the same figure Is there any way to adjust the map and graph position and obtain this? Thanks!

Upvotes: 1

Views: 420

Answers (2)

Arne Babenhauserheide
Arne Babenhauserheide

Reputation: 2513

Did you try using m.plot() instead of pyl.plot()? (and no clf() in between)

Upvotes: 0

FakeDIY
FakeDIY

Reputation: 1445

I might be misunderstanding your question but you can use subplot() in matplotlib to produce multiple plots on the same figure.

Upvotes: 1

Related Questions