Skip to content

Commit

Permalink
Merge pull request #616 from ajdawson/quickplot-time-units
Browse files Browse the repository at this point in the history
Remove quickplot unit label for time reference coordinates. Closes #615.
  • Loading branch information
esc24 committed Jul 17, 2013
2 parents c49fc0b + 75a529f commit 19584ad
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/iris/quickplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions lib/iris/tests/test_quickplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

0 comments on commit 19584ad

Please sign in to comment.