我正在尝试将带有添加色条的四面板图保存为.eps图,但是,仅保存了面板图,从应该位于图底部的add_axes中切断了色条。有谁知道如何确保颜色栏得到保存?代码在下面,谢谢。
fig = plt.figure(figsize=(4.5,3.75))
ax = plt.subplot(221)
lats,lons = wrf.latlon_coords(totrain)
bm = wrf.get_basemap(rainc)
bm.drawcoastlines(linewidth=0.25)
bm.drawstates(linewidth=0.25)
bm.drawcountries(linewidth=0.25)
bm.drawparallels(np.arange(0.,90.,5.),color='gray',dashes=[1,3],labels=[1,0,0,0])
bm.drawmeridians(np.arange(0.,360.,15.),color='gray',dashes=[1,3],labels=[0,0,0,1])
x,y = bm(wrf.to_np(lons),wrf.to_np(lats))
cx1 = bm.contourf(x,y,wrf.to_np(all_rain[0]),np.arange(0,np.max(all_rain)+15,15),cmap=cmap)
text_box = AnchoredText('a)',frameon=False,loc=2,pad=0.1,prop=dict(fontweight='bold',fontsize=10.))
plt.setp(text_box.patch,facecolor='white',alpha=0.5)
ax.add_artist(text_box)
ax2 = plt.subplot(222)
lats,lons = wrf.latlon_coords(totrain)
bm = wrf.get_basemap(rainc)
bm.drawcoastlines(linewidth=0.25)
bm.drawstates(linewidth=0.25)
bm.drawcountries(linewidth=0.25)
bm.drawparallels(np.arange(0.,90.,5.),color='gray',dashes=[1,3],labels=[1,0,0,0])
bm.drawmeridians(np.arange(0.,360.,15.),color='gray',dashes=[1,3],labels=[0,0,0,1])
x,y = bm(wrf.to_np(lons),wrf.to_np(lats))
cx2=bm.contourf(x,y,wrf.to_np(all_rain[1]),np.arange(0,np.max(all_rain)+15,15),cmap=cmap)
text_box = AnchoredText('b)',frameon=False,loc=2,pad=0.1,prop=dict(fontweight='bold',fontsize=10.))
plt.setp(text_box.patch,facecolor='white',alpha=0.5)
ax2.add_artist(text_box)
ax3 = plt.subplot(223)
lats,lons = wrf.latlon_coords(totrain)
bm = wrf.get_basemap(rainc)
bm.drawcoastlines(linewidth=0.25)
bm.drawstates(linewidth=0.25)
bm.drawcountries(linewidth=0.25)
bm.drawparallels(np.arange(0.,90.,5.),color='gray',dashes=[1,3],labels=[1,0,0,0])
bm.drawmeridians(np.arange(0.,360.,15.),color='gray',dashes=[1,3],labels=[0,0,0,1])
x,y = bm(wrf.to_np(lons),wrf.to_np(lats))
cx3=bm.contourf(x,y,wrf.to_np(all_rain[2]),np.arange(0,np.max(all_rain)+15,15),cmap=cmap)
text_box = AnchoredText('c)',frameon=False,loc=2,pad=0.1,prop=dict(fontweight='bold',fontsize=10.))
plt.setp(text_box.patch,facecolor='white',alpha=0.5)
ax3.add_artist(text_box)
ax4 = plt.subplot(224)
lats,lons = wrf.latlon_coords(totrain)
bm = wrf.get_basemap(rainc)
bm.drawcoastlines(linewidth=0.25)
bm.drawstates(linewidth=0.25)
bm.drawcountries(linewidth=0.25)
bm.drawparallels(np.arange(0.,90.,5.),color='gray',dashes=[1,3],labels=[1,0,0,0])
bm.drawmeridians(np.arange(0.,360.,15.),color='gray',dashes=[1,3],labels=[0,0,0,1])
x,y = bm(wrf.to_np(lons),wrf.to_np(lats))
cx4=bm.contourf(x,y,wrf.to_np(all_rain[3]),np.arange(0,np.max(all_rain)+15,15),cmap=cmap)
text_box = AnchoredText('d)',frameon=False,loc=2,pad=0.1,prop=dict(fontweight='bold',fontsize=10.))
plt.setp(text_box.patch,facecolor='white',alpha=0.5)
ax4.add_artist(text_box)
fig.tight_layout()
cbar_ax = fig.add_axes([0.2,-0.075,0.6,0.05])
fig.colorbar(cx4,cax=cbar_ax,shrink=0.7,orientation='horizontal',label='Accumulated Precipitation (mm)')
fig.savefig('/strm3/vecellio/Figures/Figure4Final.eps',dpi=300.)