Description
For plots with log axis that have limits of the order or less than two decades, only one label is shown:
Which does not give a very good idea of the values of the x axis. Adding labels to the minor ticks results in a mess, including non-helpful labels such as 10^{4.30}
:
ax.xaxis.set_minor_formatter(ticker.LogFormatterMathtext(labelOnlyBase=False))
And limiting them at [2,5]*base**i
results in losing all other minor ticks:
ax.xaxis.set_minor_locator(ticker.LogLocator(subs=[2,5]))
The decimals in the exponent can be resolved using LogFormatter, but it is not a nice representation for axis and requires changing the major formatter to match:
ax.xaxis.set_minor_formatter(ticker.LogFormatter(labelOnlyBase=False))
ax.xaxis.set_major_formatter(ticker.LogFormatter())
Finally, the only way to get them in a consistent manner with the major tick labels, while preserving all minor ticks, is to set them manually, which is far from ideal:
ax.xaxis.set_ticklabels([r'$2\times10^4$','','',r'$5\times10^4$','','','','',
r'$2\times 10^4$','','',r'$5\times10^4$','','','','',
r'$2\times 10^5$','','',r'$5\times10^5$','','','','',
],minor=True)
I think that there should be a LogFormatterMathtext
with a subs
options like the locator, and an option to factors instead of decimal exponents. I will take a look at the LogFormatterMathtext
and try to modify it in the following days. If it looks good, I would propose to switch to it automatically for axis spanning less than two decades.
Note that this issue has been reported in a stackoverflow question where a custom formatter is proposed as an answer.
This is somewhat related to the issue #4730 because the lack of labels is particularly noticeable when the axis is around 0.1,1,10, where it would make a lot of sense to have labels at [0.1,0.2,2,5,20,50].