【问题标题】:tricontourf breaking when contouring over 0 point in polar plot在极坐标图中轮廓超过 0 点时 tricontourf 断裂
【发布时间】:2021-11-25 03:16:44
【问题描述】:

我正在尝试在极坐标图上绘制三角形,但是在 0 经度点上绘制时似乎出现故障。

当绘制为散点图时,很明显这些点很好。

此外,在不包含 0 经度的其他位置绘制三等高线时,它工作得很好。

下面分别是三角图和散点图的代码:

    axes.tricontourf(prediction['Longitude'], prediction['Latitude'], prediction['Measurement'], levels = np.linspace(0, 2, 50), cmap='viridis', zorder=10)
    axes.scatter(prediction['Longitude'], prediction['Latitude'], c=prediction['Measurement'], cmap='viridis', zorder=10, norm = plt.Normalize(0, 2),s=10)

此外,here are the data points centred on 0 lon, 62 latthese are the ones centred on -90 lon, 62 lat

有人知道为什么会这样吗?

【问题讨论】:

    标签: python cartopy contourf visual-glitch


    【解决方案1】:

    对于任何想知道的人:解决方案是将经度从 0-360 转换为 -180-180。我通过以下两行代码实现了这一点:

    prediction['Longitude'] = (prediction['Longitude'] + 180) % 360 - 180
    prediction = prediction.sort_values('Longitude')
    

    【讨论】:

      猜你喜欢
      • 2019-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-24
      • 2021-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多