【发布时间】:2017-04-05 18:11:39
【问题描述】:
我正在尝试使用 Cartopy 在北极立体地图投影上创建等高线图。我使用add_cyclic_point() 尝试解决经度 0 和经度 35X 之间存在间隙的问题,并按照文档 (always_circular_stereographic) 中的示例设置地图轴。
当我打电话给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()?
【问题讨论】:
标签: python matplotlib cartopy