MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_minorticks_toggle

Function test_minorticks_toggle

lib/matplotlib/tests/test_ticker.py:1847–1884  ·  view source on GitHub ↗

Test toggling minor ticks Test `.Axis.minorticks_on()` and `.Axis.minorticks_off()`. Testing is limited to a subset of built-in scales - `'linear'`, `'log'`, `'asinh'` and `'logit'`. `symlog` scale does not seem to have a working minor locator and is omitted. In future, this te

()

Source from the content-addressed store, hash-verified

1845
1846
1847def test_minorticks_toggle():
1848 """
1849 Test toggling minor ticks
1850
1851 Test `.Axis.minorticks_on()` and `.Axis.minorticks_off()`. Testing is
1852 limited to a subset of built-in scales - `'linear'`, `'log'`, `'asinh'`
1853 and `'logit'`. `symlog` scale does not seem to have a working minor
1854 locator and is omitted. In future, this test should cover all scales in
1855 `matplotlib.scale.get_scale_names()`.
1856 """
1857 fig = plt.figure()
1858 def minortickstoggle(xminor, yminor, scale, i):
1859 ax = fig.add_subplot(2, 2, i)
1860 ax.set_xscale(scale)
1861 ax.set_yscale(scale)
1862 if not xminor and not yminor:
1863 ax.minorticks_off()
1864 if xminor and not yminor:
1865 ax.xaxis.minorticks_on()
1866 ax.yaxis.minorticks_off()
1867 if not xminor and yminor:
1868 ax.xaxis.minorticks_off()
1869 ax.yaxis.minorticks_on()
1870 if xminor and yminor:
1871 ax.minorticks_on()
1872
1873 assert (len(ax.xaxis.get_minor_ticks()) > 0) == xminor
1874 assert (len(ax.yaxis.get_minor_ticks()) > 0) == yminor
1875
1876 scales = ['linear', 'log', 'asinh', 'logit']
1877 for scale in scales:
1878 minortickstoggle(False, False, scale, 1)
1879 minortickstoggle(True, False, scale, 2)
1880 minortickstoggle(False, True, scale, 3)
1881 minortickstoggle(True, True, scale, 4)
1882 fig.clear()
1883
1884 plt.close(fig)
1885
1886
1887@pytest.mark.parametrize('remove_overlapping_locs, expected_num',

Callers

nothing calls this directly

Calls 4

minortickstoggleFunction · 0.85
figureMethod · 0.80
clearMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…