簡體   English   中英

Cartopy 無法在 EckertIII 的投影中顯示緯度標簽

[英]Cartopy cannot show latitude labels in projection of EckertIII

Cartopy 沒有在簡單的 plot 中顯示緯度標簽。 可以設置什么來顯示緯度標簽? 代碼將創建圖形,但未顯示緯度標簽。 如果將投影更改為 PlateCarree,則顯示標簽沒有問題。

在此處輸入圖像描述

python 代碼為:

 # Setup a global EckertIII map with faint coastlines. fig = plt.figure(figsize=(16, 8)) ax = fig.add_subplot(2,2,1, projection=ccrs.EckertIII()) # ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) x = np.arange(-90, 90) y = x.copy() x2, y2 = np.meshgrid(x, y) z = x2*y2 filled_c = ax.contourf(x2, y2, z, transform=ccrs.PlateCarree()) line_c = ax.contour(x2, y2, z, levels=filled_c.levels, colors=['black'], transform=ccrs.PlateCarree()) plt.colorbar(filled_c, orientation='vertical', ax=ax) ax.set_global() ax.coastlines('110m', alpha=0.1) # Use the line contours to place contour labels. ax.clabel( line_c, # Typically best results when labelling line contours. colors=['black'], manual=False, # Automatic placement vs manual placement. inline=True, # Cut the line where the label will be placed. fmt=' {:.0f} '.format, # Labes as integers, with some extra space. ) # # s0 # ax.gridlines(color='k', linestyle='--', draw_labels=True) # # s1 gl = ax.gridlines( xlocs=[-180, -120, -60, 0, 60, 120, 180], ylocs=[-90, -60, -30, 0, 30, 60, 90], draw_labels=True, x_inline=False, y_inline=False, lw=0.5, linestyle='--', color='gray' ) # gl.top_labels = False # gl.right_labels = True gl.rotate_labels = False

我自己解決了這個問題,為該圖形運行了兩次網格線。 第一次運行設置旋轉標簽為真,第二次運行設置為假。 然后將為它們繪制網格線。

 # 1st to draw the rotate labels gl = ax.gridlines(color='k', linestyle='--', lw=0.5, draw_labels=True) # 2nd to draw the non-rotate labels gl = ax.gridlines(color='k', linestyle='--', lw=0.5, draw_labels=True) gl.rotate_labels = False

暫無
暫無

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

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