[Matplotlib-users] Autoscaling Date Locator with minor ticks?

Akkana Peck akkana at shallowsky.com
Fri May 3 21:09:08 EDT 2019

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:
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.



More information about the Matplotlib-users mailing list