2
我试图在使用Cartopy的北极地区立体地形图投影上创建等高线图。我使用add_cyclic_point()
来尝试解决经度0和经度35X之间存在差距的问题,并遵循文档(always_circular_stereographic
)中的示例来设置地图坐标轴。Cartopy极地立体图中的等高线的奇怪行为
当我打电话给plt.contour
时,我得到下面的图。看起来轮廓绘图仪在从355到0经度的过渡时变得困惑,并在全球发送等高线。
这里是我的代码:
import numpy as np
import cartopy.crs as ccrs
from cartopy.util import add_cyclic_point
import matplotlib.pyplot as plt
def define_map():
from matplotlib.path import Path
fig = plt.figure(figsize=(10,10))
ax = plt.axes(projection=ccrs.NorthPolarStereo())
ax.coastlines()
# From example: http://scitools.org.uk/cartopy/docs/latest/examples/always_circular_stereo.html
theta = np.linspace(0, 2*np.pi, 100)
center, radius = [0.5, 0.5], 0.5
verts = np.vstack([np.sin(theta), np.cos(theta)]).T
circle = Path(verts * radius + center)
ax.set_boundary(circle, transform=ax.transAxes)
return(fig, ax)
lats = np.arange(65,91,5)
lons = add_cyclic_point(np.arange(0,359,5))
data = add_cyclic_point(np.random.random((len(lats),len(lons)-1)))
fig, ax = define_map()
plt.contour(lons,lats,data,5,transform=ccrs.PlateCarree(), cmap=plt.cm.Blues)
plt.colorbar(fraction=0.05, shrink=0.9)
plt.show()
我如何做一个Cartopy等高线图,正常吗? 此外,为什么轮廓只显示transform=ccrs.PlateCarree()
而不是transform=ccrs.NorthPolarStereo()
?