Cartopy: order of rendering layers with scatter data

倾然丶 夕夏残阳落幕 提交于 2019-12-01 03:01:43

问题


I am trying to plot position of several points (scatter plot) on a map using Cartopy (see code below). When I try to render the plot, data-points are rendered behind LAND-layer. But I want to plot my scatter-data over LAND-layer... What I am doing wrong?

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()


回答1:


Most, if not all, matplotlib plotting functions take a zorder parameter to specify the drawing order.

Lower zorders will be drawn first, and as such higher zorders will appear "on top".

So yeah, pass in zorder=xxx to arrange your layers.



来源:https://stackoverflow.com/questions/26923673/cartopy-order-of-rendering-layers-with-scatter-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!