守渺 2022-11-07 16:04 采纳率: 0%
浏览 29
已结题

python 地图 与中心经度有关


大家好,我最近在画气象数据的全球分布图。我需要画两张图,一张中心经度在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)  外,其余位置均与前者代码相同。

我希望中心经度改变后,数据也能跟着挪动。

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 11月15日
    • 创建了问题 11月7日

    悬赏问题

    • ¥15 Xsheii7我安装这个文件的时候跳出来另一个文件已锁定文件的无一部分进程无法访问。这个该怎么解决
    • ¥15 unity terrain打包后地形错位,跟建筑不在同一个位置,怎么办
    • ¥15 FileNotFoundError 解决方案
    • ¥15 uniapp实现如下图的图表功能
    • ¥15 u-subsection如何修改相邻两个节点样式
    • ¥30 vs2010开发 WFP(windows filtering platform)
    • ¥15 服务端控制goose报文控制块的发布问题
    • ¥15 学习指导与未来导向啊
    • ¥15 求多普勒频移瞬时表达式
    • ¥15 如果要做一个老年人平板有哪些需求