繁体   English   中英

Cartopy 极坐标立体图中轮廓的奇怪行为

[英]Strange behavior with contours in Cartopy polar stereographic plot

我正在尝试使用 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()

显然add_cyclic_point函数只是为了数据; 轮廓例程处理 0 与 360 不同。所以简单的解决方法是设置

lons = np.arange(0,360,5)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM