Skip to content

Instantly share code, notes, and snippets.

@dennissergeev
Last active May 18, 2020 14:19
Show Gist options
  • Save dennissergeev/d52c4265db78488ee66bff9ee9797585 to your computer and use it in GitHub Desktop.
Save dennissergeev/d52c4265db78488ee66bff9ee9797585 to your computer and use it in GitHub Desktop.
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())
@multilingualtricker
Copy link

Thanks Denis! Much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment