diff --git a/lib/iris/quickplot.py b/lib/iris/quickplot.py index 032fee557c..aab4226661 100644 --- a/lib/iris/quickplot.py +++ b/lib/iris/quickplot.py @@ -100,8 +100,10 @@ def _label_with_points(cube, result=None, ndims=2, coords=None): def _get_titles(u_object, v_object): if u_object is None: u_object = iplt._u_object_from_v_object(v_object) - xlabel = _title(u_object, with_units=True) - ylabel = _title(v_object, with_units=True) + xunits = u_object is not None and not u_object.units.is_time_reference() + yunits = not v_object.units.is_time_reference() + xlabel = _title(u_object, with_units=xunits) + ylabel = _title(v_object, with_units=yunits) title = '' if u_object is None: title = _title(v_object, with_units=False) diff --git a/lib/iris/tests/results/visual_tests/test_quickplot.TestTimeReferenceUnitsLabels.test_not_reference_time_units.0.png b/lib/iris/tests/results/visual_tests/test_quickplot.TestTimeReferenceUnitsLabels.test_not_reference_time_units.0.png new file mode 100644 index 0000000000..dd784e2ffc Binary files /dev/null and b/lib/iris/tests/results/visual_tests/test_quickplot.TestTimeReferenceUnitsLabels.test_not_reference_time_units.0.png differ diff --git a/lib/iris/tests/results/visual_tests/test_quickplot.TestTimeReferenceUnitsLabels.test_reference_time_units.0.png b/lib/iris/tests/results/visual_tests/test_quickplot.TestTimeReferenceUnitsLabels.test_reference_time_units.0.png new file mode 100644 index 0000000000..f0a64ae9a7 Binary files /dev/null and b/lib/iris/tests/results/visual_tests/test_quickplot.TestTimeReferenceUnitsLabels.test_reference_time_units.0.png differ diff --git a/lib/iris/tests/test_quickplot.py b/lib/iris/tests/test_quickplot.py index 2593673c64..065c705e8b 100644 --- a/lib/iris/tests/test_quickplot.py +++ b/lib/iris/tests/test_quickplot.py @@ -21,6 +21,8 @@ # import iris tests first so that some things can be initialised before importing anything else import iris.tests as tests +import matplotlib.pyplot as plt + import iris import iris.plot as iplt import iris.quickplot as qplt @@ -172,5 +174,24 @@ def test_alignment(self): self.check_graphic() +@tests.skip_data +class TestTimeReferenceUnitsLabels(tests.GraphicsTest): + + def setUp(self): + path = tests.get_data_path(('PP', 'aPProt1', 'rotatedMHtimecube.pp')) + self.cube = iris.load_cube(path)[:, 0, 0] + + def test_reference_time_units(self): + # units should not be displayed for a reference time + qplt.plot(self.cube.coord('time'), self.cube) + plt.gcf().autofmt_xdate() + self.check_graphic() + + def test_not_reference_time_units(self): + # units should be displayed for other time coordinates + qplt.plot(self.cube.coord('forecast_period'), self.cube) + self.check_graphic() + + if __name__ == "__main__": tests.main()