我试图绘制全球风暴轨迹,但当风暴穿过日期线(经度从~360到~0)时,该线会在绘图空间中一路循环。 Here's what the plot looks like. See the weird straight lines near the top. 这是我的密码:
ax = plt.axes(projection=ccrs.Robinson())
ax.set_global()
ax.coastlines()
for i in range(nstorms-1): #loop through each TC
bidx = start_idx[i]
eidx = start_idx[i+1]
plt.plot(clons[bidx:eidx],clats[bidx:eidx],transform=ccrs.PlateCarree())
要绘制跨越日期线的多段线,需要正确清理经度。例如,值359到2应调整为359到362。在下面的演示代码中,
sanitize_lonlist()
用于在绘制红色之字形线之前对经度值列表进行清理使用
xdateline
的原始值绘制代码行:-该地块将为:-
根据this github issue,这是预期的行为,因为
PlateCarree
是投影坐标系一种解决方案是在绘图调用中使用大地坐标变换:
或者在使用
PlateCarree
系统时修改数据以使其更有意义,例如,通过标识值从360->;0,然后将360添加到所有值。您可以将它们移到不同的范围(例如-180..180),但数据交叉+/-180的问题与当前0/360的问题相同相关问题 更多 >
编程相关推荐