|
From: Skip M. <sk...@po...> - 2013-07-10 19:40:21
|
I have a small matplotlib app I wrote to plot columns of a CSV files. The X axis is almost always time. Once displayed, I will often zoom in on a small patch of a plot. I'm currently selecting the strftime format based on the original time range of the input. As I zoom in, however, that doesn't work so well. Consider the attached plot. How do I trigger a recalculation of the X axis format? I see this class, which looks promising: http://matplotlib.org/api/dates_api.html#matplotlib.dates.AutoDateFormatter but when I use it in the obvious way, all I get is the current year for all tick labels, despite the fact that the scaled attribute of the formatter has keys which are much smaller than a year. formatter = matplotlib.dates.AutoDateFormatter( matplotlib.dates.AutoDateLocator()) print formatter.scaled The default scaled attribute displays as: {1.0: '%b %d %Y', 365.0: '%Y', 30.0: '%b %Y', 0.041666666666666664: '%H:%M:%S'} I'm plotting data now with a range of about four hours, so I think the last format (%H:%M:%S) should be used. Thx, Skip |