Skip to content

Commit

Permalink
MNT: Avoid some UnitStrippedWarnings
Browse files Browse the repository at this point in the history
Avoid passing Quantity instances to matplotlib plots that don't support
them in the declarative interface.
  • Loading branch information
dopplershift committed Nov 3, 2023
1 parent 888036c commit 72379ff
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/metpy/plots/declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,8 @@ def _build(self):
kwargs.setdefault('colors', self.linecolor)
kwargs.setdefault('linestyles', self.linestyle)

self.handle = self.parent.ax.contour(x_like, y_like, imdata, self.contours, **kwargs)
self.handle = self.parent.ax.contour(x_like, y_like, imdata.metpy.dequantify(),
self.contours, **kwargs)
if self.clabels:
self.handle.clabel(inline=1, fmt='%.0f', inline_spacing=8,
use_clabeltext=True, fontsize=self.label_fontsize)
Expand Down Expand Up @@ -1205,11 +1206,13 @@ def griddata(self):

if self.plot_units is not None:
data_subset_u = data_subset_u.metpy.convert_units(self.plot_units)
data_subset_u = data_subset_u.metpy.dequantify()
data_subset_v = data_subset_v.metpy.convert_units(self.plot_units)
data_subset_v = data_subset_v.metpy.dequantify()
self._griddata_u = data_subset_u * self.scale
self._griddata_v = data_subset_v * self.scale

return (self._griddata_u, self._griddata_v)
return self._griddata_u, self._griddata_v

@property
def plotdata(self):
Expand Down

0 comments on commit 72379ff

Please sign in to comment.