NorthPolarStereo的中央经度

时间:2013-01-05 15:17:17

标签: cartopy

我想绘制北半球的极地立体图,在图的底部有180,所以我可以强调太平洋地区。我正在使用git中的最新版本,并且可以使极地立体图没有问题,但我无法弄清楚如何改变经验底部的情节。我尝试将经度范围设置为[-180,180],但这没有帮助,NorthPolarStereo()不接受任何关键字参数,如central_longitude。这目前可能吗?

2 个答案:

答案 0 :(得分:3)

此功能现已在Cartopy(v0.6.x)中实现。以下示例在北半球极地立体投影中生成两个子图,一个具有默认设置,另一个具有中心经度变化:

"""Stereographic plot with adjusted central longitude."""
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.examples.waves import sample_data


# read sample data
x, y, z = sample_data(shape=(73, 145))

fig = plt.figure(figsize=(8, 4))

# first plot with default settings
ax1 = fig.add_subplot(121, projection=ccrs.NorthPolarStereo())
cs1 = ax1.contourf(x, y, z, 50, transform=ccrs.PlateCarree(),
                   cmap='gist_ncar')
ax1.set_extent([0, 360, 0, 90], crs=ccrs.PlateCarree())
ax1.coastlines()
ax1.set_title('Centred on 0$^\circ$ (default)')

# second plot with 90W at the bottom of the plot
ax2 = fig.add_subplot(
    122, projection=ccrs.NorthPolarStereo(central_longitude=-90))
cs2 = ax2.contourf(x, y, z, 50, transform=ccrs.PlateCarree(),
                   cmap='gist_ncar')
ax2.set_extent([0, 360, 0, 90], crs=ccrs.PlateCarree())
ax2.coastlines()
ax2.set_title('Centred on 90$^\circ$W')

plt.show()

此脚本的输出为:

NH polar stereographic

答案 1 :(得分:1)

对于Cartopy 0.17和matplotlib 3.1.1(Python 3.7),使用上述解决方案在set_extent()中出现错误。

set_extent()似乎仅以这种方式工作:

ax1.set_extent([-180, 180, 0, 90], crs=ccrs.PlateCarree())

ax2.set_extent([-179, 179, 0, 90], crs=ccrs.PlateCarree())

所以,旋转的图像需要一些奇怪的经度边界。.