Created
May 4, 2020 20:05
-
-
Save philippemiron/cebccfcb199a94ebba1e8bce597ce6a6 to your computer and use it in GitHub Desktop.
Problem with cartopy NaturalEarthFeature bathymetry feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import cartopy.feature as cfeature | |
import cartopy.crs as ccrs | |
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter | |
fig = plt.figure(figsize=(10, 4), dpi=300) | |
ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree(), aspect='equal') | |
ax.set_extent([-80, 10, 35, 80], crs=ccrs.PlateCarree()) | |
# ticks | |
ax.set_xticks(np.arange(-80, 20, 20), crs=ccrs.PlateCarree()) | |
ax.set_yticks(np.arange(40, 100, 20), crs=ccrs.PlateCarree()) | |
ax.xaxis.set_major_formatter(LongitudeFormatter()) | |
ax.yaxis.set_major_formatter(LatitudeFormatter()) | |
# add land and coastline and 1000m bathymetry line | |
ax.add_feature(cfeature.LAND, facecolor='grey', zorder=1) | |
ax.add_feature(cfeature.COASTLINE, linewidth=0.25, zorder=1) | |
bathym = cfeature.NaturalEarthFeature(name='bathymetry_J_1000', scale='10m', category='physical') | |
ax.add_feature(bathym, facecolor='none', edgecolor='black') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I got help on Github.
Here is an updated code.