大家好,我最近在画气象数据的全球分布图。我需要画两张图,一张中心经度在0,一张中心经度在180。我设置了proj = ccrs.PlateCarree(central_longitude=180)。但是出现了问题:地理范围移动了,但是数据的分布并没有移动。请问能指点我一下吗?
中心经度为0代码:
fig = plt.figure(figsize=(5,5), dpi=500)
proj = ccrs.PlateCarree()
extent=[-180,180,-72,52]
ax1 = fig.add_subplot(4,2,1, projection=proj)
ax1.set_extent(extent,ccrs.PlateCarree())
ax1.add_feature(cfeature.COASTLINE.with_scale('110m'), linewidth=0.2,color='k')
ax1.spines['geo'].set_linewidth(0.5)#调节边框粗细
sca_1 = ax1.scatter(lon,lat,c = AOD[7],cmap=ccmap,vmin=0,vmax=1.,s=0.05)
ax1.scatter(175.38,-20.57,c='#000000',s =1.5,marker='1',transform=ccrs.PlateCarree())
g1 = ax1.gridlines(draw_labels=True,linestyle=":",linewidth=0.3,x_inline=False,y_inline=False,color='k')
g1.top_labels,g1.bottom_labels,g1.right_labels,g1.left_labels = False,False,False,False
g1.xlocator = mticker.FixedLocator(np.arange(-180,180,60))
g1.ylocator = mticker.FixedLocator(np.arange(-60,40,20))
ax1.xaxis.set_major_formatter(LongitudeFormatter())
ax1.yaxis.set_major_formatter(LatitudeFormatter())
ax1.set_xticks([-120,-60,0,60,120,180], crs=ccrs.PlateCarree())
ax1.set_yticks(np.arange(-60,60,20), crs=ccrs.PlateCarree())
ax1.tick_params(labelcolor='k',length=2)
ax1.tick_params(axis='x', labelsize=1)
ax1.tick_params(axis='y', labelsize=1)
plt.colorbar(sca_1,fraction=0.016,
ticks=[0,0.2,0.4,0.6,0.8,1.0])
ax1.set_title(title[7],fontsize=15,loc='left')
plt.show()
中心经度为180代码:
fig = plt.figure(figsize=(5,5), dpi=500)
proj = ccrs.PlateCarree(central_longitude=180)
extent=[-180,180,-72,52]
ax1 = fig.add_subplot(4,2,1, projection=proj)
ax1.set_extent(extent,ccrs.PlateCarree())
ax1.add_feature(cfeature.COASTLINE.with_scale('110m'), linewidth=0.2,color='k')
ax1.spines['geo'].set_linewidth(0.5)#调节边框粗细
sca_1 = ax1.scatter(lon,lat,c = AOD[7],cmap=ccmap,vmin=0,vmax=1.,s=0.05)
ax1.scatter(175.38,-20.57,c='#000000',s =1.5,marker='1',transform=ccrs.PlateCarree())
g1 = ax1.gridlines(draw_labels=True,linestyle=":",linewidth=0.3,x_inline=False,y_inline=False,color='k')
g1.top_labels,g1.bottom_labels,g1.right_labels,g1.left_labels = False,False,False,False
g1.xlocator = mticker.FixedLocator(np.arange(-180,180,60))
g1.ylocator = mticker.FixedLocator(np.arange(-60,40,20))
ax1.xaxis.set_major_formatter(LongitudeFormatter())
ax1.yaxis.set_major_formatter(LatitudeFormatter())
ax1.set_xticks([-120,-60,0,60,120,180], crs=ccrs.PlateCarree())
ax1.set_yticks(np.arange(-60,60,20), crs=ccrs.PlateCarree())
ax1.tick_params(labelcolor='k',length=2)
ax1.tick_params(axis='x', labelsize=1)
ax1.tick_params(axis='y', labelsize=1)
plt.colorbar(sca_1,fraction=0.016,
ticks=[0,0.2,0.4,0.6,0.8,1.0])
ax1.set_title(title[7],fontsize=5,loc='left')
即:除了第五行使用ax1 = fig.add_subplot(4,2,1, projection=proj), proj = ccrs.PlateCarree(central_longitude=180) 外,其余位置均与前者代码相同。
我希望中心经度改变后,数据也能跟着挪动。