diff --git a/src/metpy/plots/declarative.py b/src/metpy/plots/declarative.py index 6080fc0c93..540cb13462 100644 --- a/src/metpy/plots/declarative.py +++ b/src/metpy/plots/declarative.py @@ -587,12 +587,14 @@ class SkewtPanel(PanelTraits, Panel): ylimits = Tuple(Int(), Int(), default_value=(1000, 100), allow_none=True) ylimits.__doc__ = """A tuple of y-axis limits to plot the skew-T. - Order is in higher pressure to lower pressure.""" + Order is in higher pressure to lower pressure. Assumption is that y-limit values are + hPa.""" xlimits = Tuple(Int(), Int(), default_value=(-40, 40), allow_none=True) xlimits.__doc__ = """A tuple of x-axis limits to plot the skew-T. - Order is lower temperature to higher temperature.""" + Order is lower temperature to higher temperature. Assumption is that x-limit values are + Celsius.""" ylabel = Unicode(default_value='pressure [hPa]') ylabel.__doc__ = """A string to plot for the y-axis label. diff --git a/src/metpy/plots/skewt.py b/src/metpy/plots/skewt.py index 32bdda4668..1d1beb273c 100644 --- a/src/metpy/plots/skewt.py +++ b/src/metpy/plots/skewt.py @@ -622,13 +622,15 @@ def plot_labeled_skewt_lines(self): r"""Plot common skewt lines and labels. This function plots the three common SkewT lines, dry adiabats, moist adiabats, - and mixing ratio lines with labels using a default coloring. + and mixing ratio lines with labels using a default coloring. Function assumes + that temperature value limits are in Celsius and pressure value limits are in + hPa. """ from metpy.constants import Cp_d, Rd # Get axes x, y limits xmin, xmax = self.ax.get_xlim() - ymax, ymin = self.ax.get_ylim() + ymax, _ = self.ax.get_ylim() # Pressure for plotting mixing ratio lines pressure = units.Quantity(np.linspace(500, ymax, 25)[::-1], 'hPa') @@ -636,7 +638,7 @@ def plot_labeled_skewt_lines(self): # Set plotting certain mixing ratio values mixing_ratio = units.Quantity(np.array([0.1, 0.2, 0.4, 0.6, 1, 1.5, 2, 3, 4, 6, 8, 10, 13, 16, 20, 25, 30, 36, 42 - ]).reshape(-1, 1), 'g/kg') + ]).reshape(-1, 1)[:, 0], 'g/kg') # Calculate the dewpoint at 500 hPa based on the mixing ratio (for plotting mixing # ratio values) @@ -674,10 +676,7 @@ def plot_labeled_skewt_lines(self): # Add saturation mixing ratio labels for i in range(mixing_ratio.m.size): - if mixing_ratio.m[i, 0] % 1: - val = str(mixing_ratio[i, 0].m) - else: - val = int(mixing_ratio[i, 0].m) + val = str(mixing_ratio[i].m) if mixing_ratio.m[i] % 1 else int(mixing_ratio[i].m) _ = self.ax.text(plottd.m[i], 500, f'{val}', ha='center', va='bottom', weight='bold', size=8, color='dodgerblue', clip_on=True, rotation=30) diff --git a/tests/plots/test_declarative.py b/tests/plots/test_declarative.py index 878200f6de..adcf136b75 100644 --- a/tests/plots/test_declarative.py +++ b/tests/plots/test_declarative.py @@ -2247,8 +2247,7 @@ def test_declarative_plot_geometry_points(ccrs): return pc.figure -@pytest.mark.mpl_image_compare(remove_text=True, - tolerance=3.27 if MPL_VERSION.startswith('3.3') else 0.03) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance=0.03) def test_declarative_skewt_plot(): """Test plotting of a simple skewT with declarative.""" date = datetime(2016, 5, 22, 0) @@ -2276,8 +2275,7 @@ def test_declarative_skewt_plot(): return panel.figure -@pytest.mark.mpl_image_compare(remove_text=True, - tolerance=3.24 if MPL_VERSION.startswith('3.3') else 0.03) +@pytest.mark.mpl_image_compare(remove_text=True, tolerance = 0.03) def test_declarative_skewt_plot_shade_cape(): """Test plotting of a skewT with declarative and shading.""" from metpy.calc import parcel_profile