I'm trying to do a Contour Plot having the Global Map in background. Having in mind that my data have LON and LAT values, I decided to use Cartopy with MatplotLib.
The problem is that I can plot my data and the map perfectly when separated, but when I try to integrate the data with the map the Cartopy map override my data plot.
This is my code:
ax = plt.axes(projection=cartopy.crs.PlateCarree())
v = np.linspace(0, 80, 25, endpoint=True)
cp = plt.contourf(matrixLon, matrixLat, matrixTec, v, transform=cartopy.crs.PlateCarree())
plt.colorbar(cp)
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.OCEAN)
ax.add_feature(cartopy.feature.COASTLINE)
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.set_extent([-85, -30, -60, 15])
plt.title('TEC Map')
plt.show()
Plots:
It is strange because I think that the logical is the data override the map (and maybe I have to try a transparent color scale) but not the other way around.
Can someone help me with this issue?
Here is the working code that you may try and learn.
The essence is the use of
zorder
andalpha
in plt.contourf() that can be set to show or hide some features on the map.