簡體   English   中英

卡托皮米勒投影中緯度標簽的奇怪設置

[英]Weird setting of latitude labels in cartopy Miller projection

只是為了讓事情變得簡單,我復制了我的問題,從cartopy 最新版本的畫廊中改編了一個例子

fig = plt.figure(figsize=(8, 10))

miller = ccrs.Miller(central_longitude=180)

ax = fig.add_subplot(1, 1, 1, projection=miller)

ax.set_global()
ax.coastlines()
ax.set_yticks(np.arange(-90, 90.5, 30), crs=miller)
lat_formatter = LatitudeFormatter()
ax.yaxis.set_major_formatter(lat_formatter)

plt.show()

在此處輸入圖像描述

由於某種原因,y 軸標簽已更改並且具有奇怪的值。 可能與 LatitudeFormatter 有關?

重要提示:出於某些與環境相關的原因,我使用的是 cartopy 0.18.0b3.dev15+

Cartopy 提供的正是您所要求的,即米勒投影中 (-90, -60, -30, 0, 30, 60, 90) 處的標簽,即不是緯度。 因為您使用的是LatitudeFormatter ,所以它將這些米勒投影點轉換為緯度以供您顯示。

看起來您想要做的是 label 在緯度/經度坐標系中,因此您應該在創建刻度時使用ccrs.PlateCarree()作為crs參數,如下所示:

import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.mpl.ticker import LatitudeFormatter
import numpy as np

fig = plt.figure(figsize=(8, 10))

miller = ccrs.Miller(central_longitude=180)

ax = fig.add_subplot(1, 1, 1, projection=miller)

ax.set_global()
ax.coastlines()
ax.set_yticks(np.arange(-90, 90.5, 30), crs=ccrs.PlateCarree())
lat_formatter = LatitudeFormatter()
ax.yaxis.set_major_formatter(lat_formatter)

plt.show()

帶有緯度標簽的米勒投影

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM