-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Unevenly spaced ticks in plot_date() #13183
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
Comments
Yes, this was an unintended consequence of #9801. Its been "fixed" by #10841 which is on master... Now "fixed" is still different to how it was before, which was (v2.2.3): If you want the old behaviour back, you need to do a bit of a song and dance. locator = mdates.AutoDateLocator(interval_multiples=False)
formatter = mdates.AutoDateFormatter(locator)
plt.plot_date(dates, data)
plt.gca().xaxis.set_major_locator(locator)
plt.gca().xaxis.set_major_formatter(formatter)
plt.grid(True)
plt.gcf().autofmt_xdate()
plt.show() I agree that the way things are in 3.0.2 are undersirable because to intervals were not good (i.e. you could get 29, 1 ticks). OTOH, I think the new behaviour (as of master) is better than the 2.2.3 behaviour. |
Oh, that sounds like a great improvement! Snapping the ticks to month edges makes a lot of sense (so long as they're still evenly spaced). I have no complaints then, and will close this issue since it's fixed already. |
No problem - sorry for the inconvenience of the bad state right now... |
Oh, sorry, "evenly spaced" for months won't work, of course.... Note the ticks are not evenly spaced above... |
Oh, right, since not all months have the same number of days. Well, it's close enough not to be jarring and is more understandable than exactly even spacing (I guess I didn't realise prior to now that this was a trade-off, I just though matplotlib had been choosing the ticks poorly for no reason). |
OK, thats what "we" decided, but its good to make sure the users are happy too. These things come down to esthetic decisions, and not everyone agrees on the best defaults. BTW there will also be a new formatter available, so if you happen to be on master, your opinions on that would be welcome. https://matplotlib.org/devdocs/gallery/ticks_and_spines/date_concise_formatter.html#sphx-glr-gallery-ticks-and-spines-date-concise-formatter-py |
The ConciseDateFormatter looks great! I tried it out and can't think of any complaints against it. |
Bug report
When plotting with
plot_date()
, the x axis ticks can be unevenly spaced. It looks like when the tick spacing is less than a month, the start of the month is always present as a tick, which may mean the space between it and the previous tick is small. This can lead to overlapping tick labels and generally poor looking axes and grids.Code for reproduction
Actual outcome
Expected outcome
The plot should have evenly spaced gridlines and axis ticks, unless a custom locator has specified otherwise.
Matplotlib version
print(matplotlib.get_backend())
): Qt5AggMatplotlib, Python and numpy are installed with the OS package manager using the standard Arch Linux repositories.
The text was updated successfully, but these errors were encountered: