|
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)
|
@@ -6111,6 +6112,29 @@ def invert(x):
|
6111 | 6112 | assert_allclose(ax.get_position().extents, [0.125, 0.1, 0.9, 0.9])
|
6112 | 6113 |
|
6113 | 6114 |
|
| 6115 | +def test_secondary_minorloc(): |
| 6116 | + fig, ax = plt.subplots(figsize=(10, 5)) |
| 6117 | + ax.plot(np.arange(2, 11), np.arange(2, 11)) |
| 6118 | + def invert(x): |
| 6119 | + with np.errstate(divide='ignore'): |
| 6120 | + return 1 / x |
| 6121 | + |
| 6122 | + secax = ax.secondary_xaxis('top', functions=(invert, invert)) |
| 6123 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6124 | + mticker.NullLocator) |
| 6125 | + secax.minorticks_on() |
| 6126 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6127 | + mticker.AutoMinorLocator) |
| 6128 | + ax.set_xscale('log') |
| 6129 | + plt.draw() |
| 6130 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6131 | + mticker.LogLocator) |
| 6132 | + ax.set_xscale('linear') |
| 6133 | + plt.draw() |
| 6134 | + assert isinstance(secax._axis.get_minor_locator(), |
| 6135 | + mticker.NullLocator) |
| 6136 | + |
| 6137 | + |
6114 | 6138 | def color_boxes(fig, axs):
|
6115 | 6139 | """
|
6116 | 6140 | Helper for the tests below that test the extents of various axes elements
|
|
0 commit comments