It may be worth mentioning that the axis marking method is usually done automatically. Depending on the range of displayed values, different settings are applied, and changing the style of matplotlib to state version 2.0
Smaller ticks on the log axis are now marked when restrictions on the axis view exceed a range less than or equal to the interval between the two main ticks.
In this sense, the reported behavior is not really a mistake; it is desirable.
When it comes to changing the default axis marking, the use of automatic marking can still be used. Ticks and tags are created using locators and matplotlib.ticker formats. The desired schedule can be obtained, for example, as follows, where a MultipleLocator sets ticks every 100 units, and secondary ticks set a NullLocator . For ticks to be formatted as scalar values ββinstead of the scientific format, you can use ScalarFormatter .
from matplotlib import pyplot as plt import matplotlib.ticker plt.axis([-100, 40, 100, 1000]) plt.semilogy() plt.gca().yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(100)) plt.gca().yaxis.set_minor_locator(matplotlib.ticker.NullLocator()) plt.gca().yaxis.set_major_formatter(matplotlib.ticker.ScalarFormatter()) plt.plot([-100, 40], [100, 1000]) plt.show()

In general, this solution is much more universal than manually installing ticks via .yticks .
source share