python - 如何使用 matplotlib 在 cartopy 极地立体图中获得平滑的网格线?

标签 python matplotlib cartopy

当使用 matplotlib 和 cartopy 的 NorthPolarStereo 投影绘图时,恒定纬度网格线(平行线)不是光滑的圆。

这是一个最小的工作示例:

from matplotlib import pyplot
import cartopy.crs

ax = pyplot.axes(projection=cartopy.crs.NorthPolarStereo())
ax.set_extent((-180, 180, 60, 90), crs=cartopy.crs.PlateCarree())
ax.gridlines()

pyplot.show()

enter image description here

如您所见,纬线是点之间的一系列直线段。每条线上没有足够的点来使它们看起来平滑。如何使平行线更圆?

最佳答案

问:如何使平行线更圆?

答:您需要为 gridlines() 创建的 gridliner 对象的 n_steps 属性设置更大的值。它的默认值为 30。这里是将值设置为 90 并生成更好的绘图的相关代码。

gl = ax.gridlines(draw_labels=False, xlocs=None, ylocs=None)
gl.n_steps = 90

参见引用资料 here .

示例输出:

enter image description here

关于python - 如何使用 matplotlib 在 cartopy 极地立体图中获得平滑的网格线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57096694/

相关文章:

python - 捕获对齐的、固定宽度的整数字段的表达式,在无效的后续字符上失败

python - 在未聚焦的 Tkinter 文本小部件中突出显示单击的行

matplotlib - 如何使用 cartopy 和 matplotlib 绘制 tissot?

python - Matplotlib - 在网格中放置饼图

python - 用 cartopy : ValueError: invalid transform: Spherical contouring is not supported 轮廓

python - Cartopy 中的风倒刺和矢量 - regrid_shape 问题

python - 如何使用django中的函数显示另一个表中的值

python - 如何在 python/Django 中获取上个月的简称或完整形式的数字

python - 颜色条和多个子图的问题

python - Matplotlib 和 PyQt5 绘图