Closed
Description
Bug summary
Logarithmic tick markers do not appear if the y-axis scales a sufficient range, with the subs
keyword argument of ticker.LogLocator
set to non-trivial values.
Code for reproduction
import matplotlib.pyplot as plt
import matplotlib.ticker
import numpy as np
ll = matplotlib.ticker.LogLocator(subs=(1, 2, 5))
### The following code produces a plot with y-axis ticks at the expected locations.
fig, ax = plt.subplots()
x = np.arange(8)
plt.semilogy(x, 10 ** x)
ax.yaxis.set_major_locator(ll)
ax.yaxis.set_minor_locator(ll)
plt.title("Good Plot")
plt.show()
### The following code produces a plot with no y-axis ticks, which is unexpected and undesired.
fig, ax = plt.subplots()
x = np.arange(9) # The only change is this line
plt.semilogy(x, 10 ** x)
ax.yaxis.set_major_locator(ll)
ax.yaxis.set_minor_locator(ll)
plt.title("Bad Plot")
plt.show()
### The problem is isolated to here, which returns correct values in the first case, but np.array([]) in the second case:
print(ll.tick_values(1, 1e7))
print(ll.tick_values(1, 1e8))
Actual outcome
Expected outcome
I expect to see ticks in both cases, as appears in the "Good Plot".
Additional information
The problem is isolated to ticker.LogLocator.tick_values()
. This returns correct values in the first case (e.g., np.array([1.e-01 2.e-01 5.e-01 1.e+00 2.e+00 5.e+00 1.e+01 2.e+01 5.e+01 1.e+02 2.e+02 5.e+02])
), but np.array([])
in the second case.
Operating system
Windows
Matplotlib Version
3.5.2
Matplotlib Backend
module://backend_interagg
Python version
3.9.13
Jupyter version
No response
Installation
conda