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

Already on GitHub? Sign in to your account

AutoDateLocator interval bug #2081

Closed
senyai opened this Issue May 29, 2013 · 6 comments

Comments

Projects
None yet
3 participants

senyai commented May 29, 2013

Let me start with the code:

from datetime import datetime
from matplotlib.dates import AutoDateLocator as ADL, _UTC as UTC
dmin = datetime(2013, 1, 8, 14, 5, tzinfo=UTC())
dmax = datetime(2013, 5, 28, 14, 5, tzinfo=UTC())
# ADL().get_locator(dmin, dmax)

from matplotlib import pyplot

x = [dmin, dmax]
y = [1, 2]
pyplot.plot(x, y)
pyplot.show()

When you run it, you will see that date axis is too full. I'm not sure what is the best solution to this issue, but after removing interval = 1 in AutoDateLocator.get_locator after comment that says "# We went through the whole loop without breaking, default to 1", all my charts looked pretty well.
(matplotlib 1.2.1)
figure_1

Owner

mdboom commented May 29, 2013

This appears to be fixed in master. We are making a 1.3.0 release candidate this week, so the fix should be available quite soon.

@mdboom mdboom closed this May 29, 2013

Member

pelson commented May 29, 2013

Probably #1925. 😉

Thanks for reporting though @senyai

Member

pelson commented May 29, 2013

This appears to be fixed in master.

Actually, I've made the situation better, but it's not entirely fixed (there is a warning and the biggest value, 14, is now chosen). To fix this fully we should add a 21 day interval to https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/dates.py#L790. That is something we can do comfortably for v1.3.x.

@pelson pelson reopened this May 29, 2013

Member

pelson commented May 29, 2013

PR incoming.

senyai commented May 29, 2013

Oh. perfect. Finally AutoDateLocator has tests 😄
I hope I won't get warnings with my sane interval 👍

Member

pelson commented May 29, 2013

#2083 fixes. Thanks @senyai

EDIT: Reference the correct issue that fixes this

@pelson pelson closed this May 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment