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

Harmonize tick-resolution-choosing and tick-format-choosing logic #48

Closed
spencerkclark opened this issue Sep 5, 2020 · 4 comments
Closed
Milestone

Comments

@spencerkclark
Copy link
Member

spencerkclark commented Sep 5, 2020

The code that chooses the resolution of the ticks and the code that chooses the format of the ticks are sometimes not consistent with each other. This can lead to confusing axis tick labels, e.g. in the following example provided by @klindsay28:

import cftime
import matplotlib.pyplot as plt
import nc_time_axis

time_vals = [cftime.DatetimeNoLeap(1+year, 1+month, 15)
             for year in range(3) for month in range(12)]

x_vals = [time_val.year + time_val.dayofyr / 365.0
          for time_val in time_vals]

fig, ax = plt.subplots(1, 1)
ax.plot(time_vals, x_vals, "-o")

image

In this case a monthly resolution is chosen for the ticks, but a tick format of "%Y" is used, giving the false impression that the ticks represent the beginning of years. I would expect for monthly resolution ticks, a format of "%Y-%m" would be used. In this example this would result in a plot that looked like this:

updated

If possible it would be great if we could make sure that inconsistencies like the above example could be avoided.

xref: pydata/xarray#4401

@bjlittle
Copy link
Member

bjlittle commented Jun 7, 2021

@spencerkclark Is this still a live issue that we want to pull into v1.3.0 ?

@spencerkclark
Copy link
Member Author

Yes, this is still a live issue and would be great to fix someday. I think it can wait until a future nc-time-axis release, however, since it involves a little more than just catching up with changes in upstream packages.

@bjlittle
Copy link
Member

bjlittle commented Jun 8, 2021

@spencerkclark Awesome. Okay, agreed 👍

I'm going to create a 1.4.0 milestone, project and GH discussion, so that we can easily triage all such issues and PRs, and it'll help slowly shape the content of the next, next release 😉

@spencerkclark
Copy link
Member Author

Closed by #79.

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

No branches or pull requests

2 participants