Cartopy: order of rendering layers with scatter data

9.8k views Asked by At

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

Points shown under the LAND layer

Plot without LAND-layer

1

There are 1 answers

2
Paul H On BEST ANSWER

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.