> 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....
> 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.
I kind of got this working. I had to associate the locator with the X
axis and call it's autoscale() method before calling plot.show(). Now
I get %H:%M:%S formatting for everything, even when I'm zoomed way out
on a data set containing two-days worth of time series data. I
suppose I can fiddle with the AutoDateFormatter's scaled attribute,
but the default looks like it ought to work. Any thoughts on what I'm
(still) missing?
The locator/formatter code looks like this:
locator = matplotlib.dates.AutoDateLocator()
formatter = matplotlib.dates.AutoDateFormatter(locator)
...
left_plot = figure.add_subplot(111)
left_plot.set_title(title)
left_plot.set_axisbelow(True)
left_plot.yaxis.set_major_formatter(pylab.FormatStrFormatter('%g'))
...
locator.set_axis(left_plot.xaxis)
left_plot.xaxis.set_major_formatter(formatter)
locator.autoscale()
pylab.show()
This works fine except for the lack of dynamic scaling and apparently
incorrect choice of labels on plots over large time scales.
Skip
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users