I'm seeing some strange behavior in the x-axis auto-labeling for dates in matplotlib. When I issue the command:
from datetime import datetime as dt
plot( [ dt(2013, 1, 1), dt(2013, 5, 17)], [ 1 , 1 ], linestyle='None', marker='.')
I get the very reasonably labeled chart:
But if I increase the end date by 1 day:
plot( [ dt(2013, 1, 1), dt(2013, 5, 18)], [ 1 , 1 ], linestyle='None', marker='.')
I get this:
I've reproduced this at several different calendar date ranges(in 2012), and each time the magic number of days required to trip the bug is around 140 (in this case 136/137). Anyone know what's going on here? Is this a known bug, and if so, is there a workaround?
A couple notes: In the above commands, I'm using IPython in --pylab mode to create the plots, but I first encountered this issue using matplotlib directly, and it is reproducible in script form (i.e. I don't think this is an IPython issue). Also, I've observed this in both matplotlib 1.1.0 and 1.2.X.
UPDATE:
It looks like there is a window where, if you push far enough ahead, the labels start behaving normally again. For the example above, the labels remain garbled from May 18 through May 31, but on June 1, the labels start plotting normally again. So,
(labels are garbled)
plot( [ dt(2013, 1, 1), dt(2013, 5, 31)], [ 1 , 1 ], linestyle='None', marker='.')
(labels are fine)
plot( [ dt(2013, 1, 1), dt(2013, 6, 1)], [ 1 , 1 ], linestyle='None', marker='.')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With