Autoscaling Date Locator with minor ticks?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Autoscaling Date Locator with minor ticks?

Akkana Peck
Is there any way to get AutoDateLocator to handle minor ticks as
well as major ones?

For instance, if I have a plot spanning a few days, I'd like to be
able to show the date as a label and major tick, but show minor
ticks for hours, or one minor tick every six hours, whatever is
sensible depending on the scale. Or on a plot spanning a few years,
show labels for each year, but with 12 minor ticks showing months.
It seems like AutoDateLocator only draws major ticks.

I can write a custom date locator that handles the minor ticks
nicely, but then I don't get the nice auto-scaling of
AutoDateLocator, and if I plot a larger or smaller date range,
my labels and ticks become too crowded or too sparse.

I tried setting both major and minor locators to AutoDateLocators:
    ax.xaxis.set_major_locator(AutoDateLocator())
    ax.xaxis.set_minor_locator(AutoDateLocator())
and similarly with set_*_formatter(), but that just gave me
smeary-looking double-printed major labels and ticks.

Maybe I need to write a custom smart locator that reproduces
AutoDateLocator's auto-scaling while also handling ticks. But before
I dive into that, I thought I'd ask; I can't be the only person who
needs more precise ticks and labeling than AutoDateLocator provides.

Thanks!

        ...Akkana
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users