Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cartopy: order of rendering layers with scatter data

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

like image 346
bubble Avatar asked Nov 14 '14 05:11

bubble


1 Answers

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.

like image 149
Paul H Avatar answered Nov 10 '22 00:11

Paul H