Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove quickplot unit label for time reference coordinates. Closes #615. #616

Merged
merged 1 commit into from
Jul 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()