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

More sensible time axis and tick labels for 2D plots #5561

Merged
merged 6 commits into from Nov 3, 2023

Conversation

rcomer
Copy link
Member

@rcomer rcomer commented Oct 31, 2023

🚀 Pull Request

Description

  1. Removed the date2num conversions from datetimes to floats in plot.py. I'm not clear why these were there, but I assume were an ancient workaround for something. They had been there since the initial commit to github. Without them, the time axis ticks get labelled with datetime information instead of floats (see the updated images in the test data PR).
  2. Pulled in the axis label change from removed units for time coords due to not matching autoticks #5484. As discussed at Quickplot Automatic Time Axis Label Completely Incorrect #5426, we only want to label these axes as "time".
  3. Reverted the quickplot change from Remove quickplot unit label for time reference coordinates. Closes #615. #616, as [2] is a more general version of this.

Closes #5484 and closes #5426


Consult Iris pull request check list

@rcomer
Copy link
Member Author

rcomer commented Oct 31, 2023

Test data PR: SciTools/iris-test-data#87

@rcomer
Copy link
Member Author

rcomer commented Oct 31, 2023

Note that users who specified a DateFormatter and DateLocator should not see any difference in their tick labels. E.g. this plot is the same with main and with my branch:

import matplotlib.pyplot as plt
import matplotlib.dates as mdates

import iris
import iris.plot as iplt
import iris.tests.stock

cube = iris.tests.stock.realistic_4d()
cube = cube[:, 0, 0, :]

fig, _ = plt.subplots(layout="constrained")

iplt.contourf(cube)
ax = plt.gca()
ax.yaxis.set_major_locator(mdates.MinuteLocator(interval=10))
ax.yaxis.set_major_formatter(mdates.DateFormatter("%M minutes after %H"))

plt.savefig("test.png")

test

lib/iris/plot.py Show resolved Hide resolved
lib/iris/plot.py Show resolved Hide resolved
lib/iris/quickplot.py Show resolved Hide resolved
lib/iris/tests/results/imagerepo.json Show resolved Hide resolved
@trexfeathers trexfeathers reopened this Nov 2, 2023
Copy link

codecov bot commented Nov 2, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cec0e09) 89.44% compared to head (62a92b7) 89.44%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5561   +/-   ##
=======================================
  Coverage   89.44%   89.44%           
=======================================
  Files          89       89           
  Lines       22597    22583   -14     
  Branches     5390     5386    -4     
=======================================
- Hits        20211    20199   -12     
+ Misses       1639     1638    -1     
+ Partials      747      746    -1     
Files Coverage Δ
lib/iris/plot.py 86.35% <ø> (-0.10%) ⬇️
lib/iris/quickplot.py 90.37% <100.00%> (+0.78%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trexfeathers trexfeathers merged commit e0850eb into SciTools:main Nov 3, 2023
25 of 31 checks passed
@rcomer rcomer deleted the contour-times branch November 3, 2023 10:58
HGWright added a commit to HGWright/iris that referenced this pull request Nov 17, 2023
* 'guess_coord' of github.com:HGWright/iris: (82 commits)
  [pre-commit.ci] auto fixes from pre-commit.com hooks
  [pre-commit.ci] pre-commit autoupdate (SciTools#5579)
  Relicense to from LGPL-3 to BSD-3 (SciTools#5577)
  Allow `add_season_year()` to optionally send spans backwards (SciTools#5573)
  Added xarray phrasebook doc page (SciTools#5564)
  fixed spacing (SciTools#5572)
  DOCS: Removed broken git links. (SciTools#5569)
  More sensible time axis and tick labels for 2D plots (SciTools#5561)
  removed now incorrect statement. (SciTools#5555)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5558)
  Exempt major release label from stalebot (SciTools#5559)
  updated link (SciTools#5556)
  Added whatsnew. (SciTools#5552)
  moved latest warning banner logic to conf.py (SciTools#5508)
  updated layout of top navbar (SciTools#5505)
  Oblique and Rotated Mercator (SciTools#5548)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5549)
  [pre-commit.ci] pre-commit autoupdate (SciTools#5527)
  Bump scitools/workflows from 2023.09.1 to 2023.10.0 (SciTools#5540)
  nep29 drop table schedule numpy>1.21 (SciTools#5525)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quickplot Automatic Time Axis Label Completely Incorrect
3 participants