Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca90947

Browse files
committed
TST: changing scale and locators secondary axis
1 parent c9bc9bc commit ca90947

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import matplotlib.markers as mmarkers
2525
import matplotlib.patches as mpatches
2626
import matplotlib.colors as mcolors
27+
import matplotlib.ticker as mticker
2728
import matplotlib.transforms as mtransforms
2829
from numpy.testing import (
2930
assert_allclose, assert_array_equal, assert_array_almost_equal)
@@ -6079,6 +6080,29 @@ def invert(x):
60796080
assert_allclose(ax.get_position().extents, [0.125, 0.1, 0.9, 0.9])
60806081

60816082

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+
60826106
def color_boxes(fig, axs):
60836107
"""
60846108
Helper for the tests below that test the extents of various axes elements

0 commit comments

Comments
 (0)