When a log scale is used the number of major ticks can be fixed with the following command
import matplotlib.pyplot as plt
....
plt.locator_params(numticks=12)
plt.show()
The value set to numticks
determines the number of axis ticks to be displayed.
Credits to @bgamari's post for introducing the locator_params()
function, but the nticks
parameter throws an error when a log scale is used.