2014-11-14 135 views
3

我想繪製使用Cartopy(請參閱下面的代碼)在地圖上繪製幾個點(散點圖)的位置。當我嘗試渲染繪圖時,數據點呈現在LAND層後面。但是我想在LAND層上畫散點數據......我做錯了什麼?Cartopy:使用散點圖數據繪製圖層的順序

Cartopy:ver。 0.12.x,Matplotlib:ver.1.4.2

import matplotlib.pyplot as plt 
import cartopy.crs as ccrs 
import cartopy.feature as cfeature 

ax = plt.axes(projection=ccrs.PlateCarree()) 
ax.set_extent([125, 150, 35, 63])   

ax.stock_img() 

ax.add_feature(cfeature.LAND) #If I comment this => all ok, but I need 
ax.add_feature(cfeature.LAKES) 
ax.add_feature(cfeature.RIVERS) 
ax.coastlines() 

ax.scatter(yc,xc,transform=ccrs.PlateCarree()) #yc, xc -- lists or numpy arrays 

plt.show() 

Points shown under the LAND layer

Plot without LAND-layer

+2

嘗試在你的調用中指定一個數字'zorder'來分散。 –

+0

謝謝!設置「zorder」解決了這個問題! – bubble

+1

@PaulH - 你介意把這個作爲答案嗎? – pelson

回答

5

大多數,如果不是全部,matplotlib繪圖函數需要zorder參數指定繪製順序。

降低zorder s將被首先繪製,並且因此更高的zorder s會出現在「頂部」。

所以是的,通過zorder=xxx來安排你的圖層。