<div dir="ltr">Akanna,<div><br></div><div>Setting the minor and major locators in the correct approach, but you need to set them with different settings (as other wise they will decide to put the ticks at the sameplaces, hence the "doubled" labels. This behavior changed with 3.1 (see <a href="https://matplotlib.org/api/api_changes.html#major-minor-tick-collisions">https://matplotlib.org/api/api_changes.html#major-minor-tick-collisions</a> ) and going forward the overlapping minor ticks will be trimmed by default).  I suspect that by playing with `minticks` and `maxticks` you can get the effect you want:</div><div><br></div><div><br></div><div>import numpy as np<br>import matplotlib.dates as mdates<br>import matplotlib.pyplot as plt<br><br>t = np.arange("2018-11-03", "2018-11-06", dtype="datetime64")<br>x = np.random.rand(len(t))<br><br>fig, ax = plt.subplots()<br>ax.plot(t, x)<br>ax.xaxis.set(<br>    major_locator=mdates.AutoDateLocator(minticks=1, maxticks=5),<br>    minor_locator=mdates.AutoDateLocator(minticks=15, maxticks=52),<br>)<br><br>plt.show()<br></div><div><br></div><div><br></div><div>You may also be interested in the ConciseDateFormatter (<a href="https://matplotlib.org/users/whats_new.html#concisedateformatter">https://matplotlib.org/users/whats_new.html#concisedateformatter</a> ) that is new in 3.1.</div><div><br></div><div>Tom</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 3, 2019 at 9:16 PM Akkana Peck <<a href="mailto:akkana@shallowsky.com">akkana@shallowsky.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Is there any way to get AutoDateLocator to handle minor ticks as<br>
well as major ones?<br>
<br>
For instance, if I have a plot spanning a few days, I'd like to be<br>
able to show the date as a label and major tick, but show minor<br>
ticks for hours, or one minor tick every six hours, whatever is<br>
sensible depending on the scale. Or on a plot spanning a few years,<br>
show labels for each year, but with 12 minor ticks showing months.<br>
It seems like AutoDateLocator only draws major ticks.<br>
<br>
I can write a custom date locator that handles the minor ticks<br>
nicely, but then I don't get the nice auto-scaling of<br>
AutoDateLocator, and if I plot a larger or smaller date range,<br>
my labels and ticks become too crowded or too sparse.<br>
<br>
I tried setting both major and minor locators to AutoDateLocators:<br>
    ax.xaxis.set_major_locator(AutoDateLocator())<br>
    ax.xaxis.set_minor_locator(AutoDateLocator())<br>
and similarly with set_*_formatter(), but that just gave me<br>
smeary-looking double-printed major labels and ticks.<br>
<br>
Maybe I need to write a custom smart locator that reproduces<br>
AutoDateLocator's auto-scaling while also handling ticks. But before<br>
I dive into that, I thought I'd ask; I can't be the only person who<br>
needs more precise ticks and labeling than AutoDateLocator provides.<br>
<br>
Thanks!<br>
<br>
        ...Akkana<br>
_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Thomas Caswell<br><a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a></div>