Skip to content

Commit

Permalink
Merge branch 'plot-bulletin-class' of https://github.com/anacmontoya/…
Browse files Browse the repository at this point in the history
…MetPy into plot-bulletin-class
  • Loading branch information
anacmontoya committed Jul 31, 2024
2 parents 3bd7d22 + d0e52ce commit 0e708d6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
34 changes: 16 additions & 18 deletions src/metpy/plots/declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

from . import ctables, wx_symbols
from ._mpl import TextCollection
from .patheffects import ColdFront, OccludedFront, WarmFront, StationaryFront
from .cartopy_utils import import_cartopy
from .patheffects import ColdFront, OccludedFront, StationaryFront, WarmFront
from .station_plot import StationPlot
from ..calc import reduce_point_density, smooth_n_point, zoom_xarray
from ..package_tools import Exporter
Expand Down Expand Up @@ -2186,14 +2186,13 @@ def _draw_strengths(self, text, lon, lat, color, offset=None):
if offset is None:
offset = tuple(x * self.label_fontsize * 0.8 for x in self.strength_offset)

self.parent.ax.add_artist(TextCollection([lon], [lat], [str(text)],
va='center',
ha='center',
color=color,
offset=offset,
weight='demi',
size=int(self.label_fontsize * 0.7),
transform=ccrs.PlateCarree()))
self.parent.ax.scattertext([lon], [lat], [str(text)],
color=color,
loc=offset,
weight='demi',
size=int(self.label_fontsize * 0.7),
transform=ccrs.PlateCarree(),
clip_on=True)

def _draw_labels(self, text, lon, lat, color, offset=(0, 0)):
"""Draw labels in the plot.
Expand All @@ -2211,14 +2210,13 @@ def _draw_labels(self, text, lon, lat, color, offset=(0, 0)):
offset : tuple (default: (0, 0))
A tuple containing the x- and y-offset of the label, respectively
"""
self.parent.ax.add_artist(TextCollection([lon], [lat], [str(text)],
va='center',
ha='center',
color=color,
offset=offset,
weight='demi',
size=self.label_fontsize,
transform=ccrs.PlateCarree()))
self.parent.ax.scattertext([lon], [lat], [str(text)],
color=color,
loc=offset,
weight='demi',
size=self.label_fontsize,
transform=ccrs.PlateCarree(),
clip_on=True)

def draw(self):
"""Draw the plot."""
Expand All @@ -2233,7 +2231,7 @@ def copy(self):

def _build(self):
"""Build the plot by calling needed plotting methods as necessary."""
from shapely.geometry import (LineString, Point)
from shapely.geometry import LineString, Point

# Ensure strength is a valid iterable
strengths = self.strength if len(self.strength) > 0 else cycle([None])
Expand Down
6 changes: 3 additions & 3 deletions tests/plots/test_declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

from metpy.calc import wind_speed
from metpy.cbook import get_test_data
from metpy.io import (GiniFile, parse_wpc_surface_bulletin)
from metpy.io import GiniFile, parse_wpc_surface_bulletin
from metpy.io.metar import parse_metar_file
from metpy.plots import (ArrowPlot, BarbPlot, ContourPlot, FilledContourPlot, ImagePlot,
MapPanel, PanelContainer, PlotGeometry, PlotObs, RasterPlot,
PlotSurfaceAnalysis)
MapPanel, PanelContainer, PlotGeometry, PlotObs, PlotSurfaceAnalysis,
RasterPlot)
from metpy.testing import needs_cartopy, version_check
from metpy.units import units

Expand Down

0 comments on commit 0e708d6

Please sign in to comment.