diff --git a/.travis.yml b/.travis.yml index d7de0dd3014..cc752f33152 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,7 +52,7 @@ matrix: include: - python: 2.7 env: - - VERSIONS="numpy==1.12.0 matplotlib==2.0.0 scipy==0.17.0 pint==0.8 xarray==0.10.7, pandas==0.20.0" + - VERSIONS="numpy==1.12.0 matplotlib==2.0.0 scipy==0.17.0 pint==0.8 xarray==0.10.7 pandas==0.20.0" - TASK="coverage" - TEST_OUTPUT_CONTROL="" - python: "3.7-dev" diff --git a/metpy/plots/tests/baseline/test_symbol_pandas_timeseries.png b/metpy/plots/tests/baseline/test_symbol_pandas_timeseries.png new file mode 100644 index 00000000000..f6cba4a1c62 Binary files /dev/null and b/metpy/plots/tests/baseline/test_symbol_pandas_timeseries.png differ diff --git a/metpy/plots/tests/test_station_plot.py b/metpy/plots/tests/test_station_plot.py index 7193935d104..9f94762a8a7 100644 --- a/metpy/plots/tests/test_station_plot.py +++ b/metpy/plots/tests/test_station_plot.py @@ -7,6 +7,7 @@ import matplotlib import matplotlib.pyplot as plt import numpy as np +import pandas as pd import pytest from metpy.plots import (current_weather, high_clouds, nws_layout, simple_layout, @@ -341,3 +342,21 @@ def test_barb_unit_conversion_exception(u, v): stnplot = StationPlot(ax, x_pos, y_pos) with pytest.raises(ValueError): stnplot.plot_barb(u, v, plot_units='knots') + + +@pytest.mark.mpl_image_compare(tolerance={'1.5': 0.0, '1.4': 0.0}.get(MPL_VERSION, 0.000), + savefig_kwargs={'dpi': 300}, remove_text=True) +def test_symbol_pandas_timeseries(): + """Test the usage of Pandas DatetimeIndex as a valid `x` input into StationPlot.""" + pd.plotting.register_matplotlib_converters() + rng = pd.date_range('12/1/2017', periods=5, freq='D') + sc = [1, 2, 3, 4, 5] + ts = pd.Series(sc, index=rng) + fig, ax = plt.subplots() + y = np.ones(len(ts.index)) + stationplot = StationPlot(ax, ts.index, y, fontsize=12) + stationplot.plot_symbol('C', ts, sky_cover) + ax.xaxis.set_major_locator(matplotlib.dates.DayLocator()) + ax.xaxis.set_major_formatter(matplotlib.dates.DateFormatter('%-d')) + + return fig