diff --git a/src/metpy/plots/declarative.py b/src/metpy/plots/declarative.py index ac7cc01cdb2..7d266b4f0ce 100644 --- a/src/metpy/plots/declarative.py +++ b/src/metpy/plots/declarative.py @@ -1423,8 +1423,8 @@ def griddata(self): if self.plot_units is not None: data_subset_u = data_subset_u.metpy.convert_units(self.plot_units) data_subset_v = data_subset_v.metpy.convert_units(self.plot_units) - self._griddata_u = data_subset_u - self._griddata_v = data_subset_v + self._griddata_u = data_subset_u * self.scale + self._griddata_v = data_subset_v * self.scale return (self._griddata_u, self._griddata_v) diff --git a/tests/plots/baseline/test_declarative_barb_scale.png b/tests/plots/baseline/test_declarative_barb_scale.png new file mode 100644 index 00000000000..858e18a9bdd Binary files /dev/null and b/tests/plots/baseline/test_declarative_barb_scale.png differ diff --git a/tests/plots/test_declarative.py b/tests/plots/test_declarative.py index e72b5c0d45d..28457f3bf97 100644 --- a/tests/plots/test_declarative.py +++ b/tests/plots/test_declarative.py @@ -632,6 +632,36 @@ def test_declarative_barb_gfs(): return pc.figure +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.607) +@needs_cartopy +def test_declarative_barb_scale(): + """Test making a contour plot.""" + data = xr.open_dataset(get_test_data('GFS_test.nc', as_file_obj=False)) + + barb = BarbPlot() + barb.data = data + barb.level = 300 * units.hPa + barb.field = ['u-component_of_wind_isobaric', 'v-component_of_wind_isobaric'] + barb.skip = (3, 3) + barb.earth_relative = False + barb.scale = 2 + + panel = MapPanel() + panel.area = 'us' + panel.projection = 'data' + panel.layers = ['coastline', 'borders', 'usstates'] + panel.plots = [barb] + + pc = PanelContainer() + pc.size = (8, 8) + pc.panels = [panel] + pc.draw() + + barb.level = 700 * units.hPa + + return pc.figure + + @pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.466) @needs_cartopy def test_declarative_barb_gfs_knots():