Skip to content

Commit

Permalink
DOC: Switch example to use scattertext
Browse files Browse the repository at this point in the history
Replaces less intuitive use of StationPlot.
  • Loading branch information
dopplershift committed Jan 4, 2025
1 parent 2f64f0d commit 03fccfe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/plots/Plotting_Surface_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from metpy.cbook import get_test_data
from metpy.io import parse_wpc_surface_bulletin
from metpy.plots import (add_metpy_logo, ColdFront, OccludedFront, StationaryFront,
StationPlot, WarmFront)
from metpy.plots import (add_metpy_logo, scattertext, ColdFront, OccludedFront,
StationaryFront, WarmFront)

###########################################
# Define a function that can be used to readily plot a bulletin that has been parsed into a
Expand All @@ -45,9 +45,10 @@ def plot_bulletin(ax, data):
for field in ('HIGH', 'LOW'):
rows = data[data.feature == field]
x, y = zip(*((pt.x, pt.y) for pt in rows.geometry), strict=False)
sp = StationPlot(ax, x, y, transform=ccrs.PlateCarree(), clip_on=True)
sp.plot_text('C', [field[0]] * len(x), **complete_style[field])
sp.plot_parameter('S', rows.strength, **complete_style[field])
scattertext(ax, x, y, [field[0]] * len(x),
**complete_style[field], transform=ccrs.PlateCarree(), clip_on=True)
scattertext(ax, x, y, [f'{v:.0f}' for v in rows.strength], loc=(0, -10),
**complete_style[field], transform=ccrs.PlateCarree(), clip_on=True)

# Handle all the boundary types
for field in ('WARM', 'COLD', 'STNRY', 'OCFNT', 'TROF'):
Expand Down

0 comments on commit 03fccfe

Please sign in to comment.