[Python] Force minor tick marks on matplotlib logarithmic axes which span many orders of...

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to add minor ticks to a plot in matplotlib. The axes are logarithmic and span 8 or 9 orders of magnitude. When it spans fewer orders of magnitude, the following code works to add the minor ticks:

    ax.xaxis.set_major_locator(mticker.LogLocator(numticks=999))
    ax.xaxis.set_minor_locator(mticker.LogLocator(numticks=999, subs="auto"))
    ax.minorticks_on()


    However this stops working when the range is larger. I don't think this is a duplicate question; nothing I've read seems to work for the specific case of logarithmic axes with a large range.

    How can I force minor ticks to appear on these axes? Thanks so much in advance!

    Continue reading...

Compartilhe esta Página