|
24 | 24 | import matplotlib.markers as mmarkers
|
25 | 25 | import matplotlib.patches as mpatches
|
26 | 26 | import matplotlib.colors as mcolors
|
| 27 | +import matplotlib.ticker as mticker |
27 | 28 | import matplotlib.transforms as mtransforms
|
28 | 29 | from numpy.testing import (
|
29 | 30 | assert_allclose, assert_array_equal, assert_array_almost_equal)
|
@@ -6079,6 +6080,29 @@ def invert(x):
|
6079 | 6080 | assert_allclose(ax.get_position().extents, [0.125, 0.1, 0.9, 0.9])
|
6080 | 6081 |
|
6081 | 6082 |
|
| 6083 | +def test_secondary_minorloc(): |
| 6084 | + fig, ax = plt.subplots(figsize=(10, 5)) |
| 6085 | + ax.plot(np.arange(2, 11), np.arange(2, 11)) |
| 6086 | + def invert(x): |
| 6087 | + with np.errstate(divide='ignore'): |
| 6088 | + return 1 / x |
| 6089 | + |
| 6090 | + secax = ax.secondary_xaxis('top', functions=(invert, invert)) |
| 6091 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6092 | + mticker.NullLocator) |
| 6093 | + secax.minorticks_on() |
| 6094 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6095 | + mticker.AutoMinorLocator) |
| 6096 | + ax.set_xscale('log') |
| 6097 | + plt.draw() |
| 6098 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6099 | + mticker.LogLocator) |
| 6100 | + ax.set_xscale('linear') |
| 6101 | + plt.draw() |
| 6102 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6103 | + mticker.NullLocator) |
| 6104 | + |
| 6105 | + |
6082 | 6106 | def color_boxes(fig, axs):
|
6083 | 6107 | """
|
6084 | 6108 | Helper for the tests below that test the extents of various axes elements
|
|
0 commit comments