- 积分
 - 57685
 
	- 贡献
 -  
 
	- 精华
 
	- 在线时间
 -  小时
 
	- 注册时间
 - 2011-6-21
 
	- 最后登录
 - 1970-1-1
 
 
 
 
 
 
 | 
	
 
 
发表于 2021-12-15 23:03:43
|
显示全部楼层
 
 
 
多个子图共用一个图例可以这样做,每个子图都不绘制图例,最后再增加一个axes专门绘制图例,可以用position参数控制图例的位置,参考下面的脚本: 
		 - f = addfile(os.path.join(migl.get_sample_folder(), 'GrADS', 'model.ctl'))
 
 - ps = f['PS'][0]
 
  
- #Plot
 
 - figure(figsize=[800, 421], newfig=False)
 
 - lchina = shaperead('cn_province')
 
 - for i in range(1, 5):
 
 -     subplot(2,2,i, axestype='map', tickfontsize=12)
 
 -     geoshow(lchina)
 
 -     layer = contourf(ps)
 
 -     xlim(72,137)
 
 -     ylim(15,55)
 
 -     yticks(arange(20,51,10))
 
  
- #new axes - add China South Sea
 
 - ll = shaperead('cn_border')
 
 - cols = [0, 1]
 
 - rows = [0, 1]
 
 - axs = []
 
 - for col in cols:
 
 -     for row in rows: 
 
 -         ax = axesm([0.335+(col*0.5), 0.06+(row*0.5), 0.14, 0.14], axison=False, frameon=True)
 
 -         axs.append(ax)
 
 -         geoshow(ll, color='b')
 
 -         xlim(106, 123)
 
 -         ylim(2, 23)
 
  
- #Add one colorbar
 
 - axes([0.2,0.2,0.26,0.5], frameon=False, axis=False)
 
 - colorbar(layer, fontsize=12)
 
  
		 
 
 |   
 
 
 
 |