Bug summary
Matplotlib 3.1 introduced a new method for adding a secondary axes with Axes.axes.secondary_xaxis and Axes.axes.secondary_xaxis. However, the .minorticks_on() method does nothing on those axes.
Code for reproduction
I use the example provided in the gallery -- https://matplotlib.org/3.1.0/gallery/subplots_axes_and_figures/secondary_axis.html -- but modify it to show minor ticks.
import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots(constrained_layout=True) x = np.arange(0, 360, 1) y = np.sin(2 * x * np.pi / 180) ax.plot(x, y) ax.set_xlabel('angle [degrees]') ax.set_ylabel('signal') ax.set_title('Sine wave') def deg2rad(x): return x * np.pi / 180 def rad2deg(x): return x * 180 / np.pi secax = ax.secondary_xaxis('top', functions=(deg2rad, rad2deg)) secax.set_xlabel('angle [rad]') ax.minorticks_on() secax.minorticks_on() plt.show()
Actual outcome
Expected outcome
The top axis is expected to have minor ticks.
Matplotlib version
#14447 fixes this, though it will (somewhat unexpectedly) get reset if you change the parent scale.
Activity
jklymak commented on Jun 4, 2019
#14447 fixes this, though it will (somewhat unexpectedly) get reset if you change the parent scale.