Last active
May 18, 2020 14:19
-
-
Save dennissergeev/d52c4265db78488ee66bff9ee9797585 to your computer and use it in GitHub Desktop.
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 matplotlib.pyplot as plt | |
import cartopy.crs as ccrs | |
import cartopy.feature as cfeature | |
from matplotlib.offsetbox import AnchoredText | |
fig = plt.figure(figsize=(10, 10)) | |
ax = fig.add_subplot(111, projection=ccrs.PlateCarree()) | |
# Set extent of the map | |
ax.set_extent([-130, -90, 10, 60], crs=ccrs.PlateCarree()) | |
# Create a feature for States/Admin 1 regions at 1:50m from Natural Earth | |
states_provinces = cfeature.NaturalEarthFeature( | |
category="cultural", | |
name="admin_1_states_provinces_lines", | |
scale="50m", | |
facecolor="none", | |
) | |
ax.add_feature(states_provinces, edgecolor="red") | |
# Create and add a feature for Coastlines at 1:110m from Natural Earth | |
ax.add_feature( | |
cfeature.NaturalEarthFeature( | |
category="physical", | |
name="coastline", | |
scale="110m", | |
facecolor="none", | |
edgecolor="#333333", | |
) | |
) | |
# Show gridlines with labels | |
ax.gridlines(draw_labels=True) | |
# Add a label | |
my_label = AnchoredText("(a) the map", loc=2, prop=dict(size=18, color='b')) | |
ax.add_artist(my_label) | |
# ADD DATA TO THE MAP | |
ax.scatter(lons, lats, facecolor='C0', edgecolor='C9', transform=ccrs.PlateCarree()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Denis! Much appreciated!