diff --git a/src/metpy/plots/station_plot.py b/src/metpy/plots/station_plot.py index 102452a98e7..2bf5d6c6593 100644 --- a/src/metpy/plots/station_plot.py +++ b/src/metpy/plots/station_plot.py @@ -24,7 +24,10 @@ class StationPlot(object): """ location_names = {'C': (0, 0), 'N': (0, 1), 'NE': (1, 1), 'E': (1, 0), 'SE': (1, -1), - 'S': (0, -1), 'SW': (-1, -1), 'W': (-1, 0), 'NW': (-1, 1)} + 'S': (0, -1), 'SW': (-1, -1), 'W': (-1, 0), 'NW': (-1, 1), + 'N2': (0, 2), 'NNE': (1, 2), 'ENE': (2, 1), 'E2': (2, 0), + 'ESE': (2, -1), 'SSE': (1, -2), 'S2': (0, -2), 'SSW': (-1, -2), + 'WSW': (-2, -1), 'W2': (-2, 0), 'WNW': (-2, 1), 'NNW': (-1, 2)} def __init__(self, ax, x, y, fontsize=10, spacing=None, transform=None, **kwargs): """Initialize the StationPlot with items that do not change. diff --git a/tests/plots/baseline/test_station_plot_locations.png b/tests/plots/baseline/test_station_plot_locations.png new file mode 100644 index 00000000000..c2e4a9142ef Binary files /dev/null and b/tests/plots/baseline/test_station_plot_locations.png differ diff --git a/tests/plots/test_station_plot.py b/tests/plots/test_station_plot.py index 4ebb5920da7..72c6883ca55 100644 --- a/tests/plots/test_station_plot.py +++ b/tests/plots/test_station_plot.py @@ -83,7 +83,28 @@ def test_station_plot_replace(): return fig -@pytest.mark.mpl_image_compare(tolerance=0, savefig_kwargs={'dpi': 300}, +@pytest.mark.mpl_image_compare(tolerance=0.25, savefig_kwargs={'dpi': 300}, remove_text=True) +def test_station_plot_locations(): + """Test that locations are properly replaced.""" + fig = plt.figure(figsize=(3, 3)) + + locations = ['C', 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'N2', 'NNE', 'ENE', 'E2', + 'ESE', 'SSE', 'S2', 'SSW', 'WSW', 'W2', 'WNW', 'NNW'] + x_pos = np.array([0]) + y_pos = np.array([0]) + + # Make the plot + sp = StationPlot(fig.add_subplot(1, 1, 1), x_pos, y_pos, fontsize=8, spacing=24) + for loc in locations: + sp.plot_text(loc, [loc]) + + sp.ax.set_xlim(-2, 2) + sp.ax.set_ylim(-2, 2) + + return fig + + +@pytest.mark.mpl_image_compare(tolerance=0.00413, savefig_kwargs={'dpi': 300}, remove_text=True) def test_stationlayout_api(): """Test the StationPlot API."""