Python 中心经度为180的cartopy集合范围

Python 中心经度为180的cartopy集合范围,python,dictionary,matplotlib,cartopy,extent,Python,Dictionary,Matplotlib,Cartopy,Extent,Cartopy 0.17.0: 设置中心经度时,我不知道如何准确设置提供的范围: import matplotlib.pyplot as plt import cartopy.crs as ccrs projection = ccrs.PlateCarree(central_longitude=180) ax = plt.axes(projection=projection) ax.coastlines() ax.set_extent((-120, 120, -45, 45), crs=ccr

Cartopy 0.17.0: 设置中心经度时,我不知道如何准确设置提供的范围:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

projection = ccrs.PlateCarree(central_longitude=180)
ax = plt.axes(projection=projection)
ax.coastlines()
ax.set_extent((-120, 120, -45, 45), crs=ccrs.PlateCarree())
ax.gridlines(draw_labels=True, crs=ccrs.PlateCarree())
这将正确划分纬度: 这将正确地子集经度,但有额外的标签:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

projection = ccrs.PlateCarree(central_longitude=180)
ax = plt.axes(projection=projection)
ax.coastlines()
ax.set_extent((-120, 120, -45, 45))
ax.gridlines(draw_labels=True, crs=ccrs.PlateCarree())
这将正确设置纬度:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs

projection = ccrs.PlateCarree(central_longitude=180)
ax = plt.axes(projection=projection)
ax.coastlines()
ax.set_extent((-120, 120, -45, 45), crs=projection)
ax.gridlines(draw_labels=True, crs=ccrs.PlateCarree())

这取决于“类PlateCarree”属性(以及所用圆柱投影的属性)。 请看地图。 经度值180是一个边框

如果设置范围[120 180…]或[-120 180…],则没有问题

我认为尝试其他投影是有意义的。

例如: 投影=ccrs.lambert圆柱(中心经度=180)


不幸的是,“无法标记Lambert圆柱网格线。目前仅支持PlateCarree网格线。

使用Cartopy绘制世界日期线地图并不像您所发现的那样简单。它需要一些技巧才能正确。最重要的是必须在代码的所有部分正确使用CRS

代码:

输出绘图1,在PlateCarree(中心经度=180)中有经度标签,这本身是自然的,但不是地理标准

如果您想在上面的图中使用普通的地理经度标签,您不能简单地使用

ax.gridlines(draw_labels=True, crs=PlateCarree())
在代码中,正如您所发现的

输出带有普通地理经度标签的绘图2

这需要ax.gridlines()中的特定指令,如下所示:

ax.gridlines(draw_labels=False, crs=ccrs.PlateCarree(), xlocs=[120,140,160,180,200,220,240])
ax.gridlines(draw_labels=True, crs=ccrs.PlateCarree(), xlocs=[120,140,160,180,-160,-140,-120])


希望这对所有读者都有用。

我希望看到整个太平洋从-45到45北纬,而不是像那样分裂。我理解。那么,也许你会选择其他投影?
ax.gridlines(draw_labels=False, crs=ccrs.PlateCarree(), xlocs=[120,140,160,180,200,220,240])
ax.gridlines(draw_labels=True, crs=ccrs.PlateCarree(), xlocs=[120,140,160,180,-160,-140,-120])