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

Function test_remove_overlap

lib/matplotlib/tests/test_ticker.py:1891–1921  ·  view source on GitHub ↗
(remove_overlapping_locs, expected_num)

Source from the content-addressed store, hash-verified

1889 (None, 6), # this tests the default
1890 (False, 9)))
1891def test_remove_overlap(remove_overlapping_locs, expected_num):
1892 t = np.arange("2018-11-03", "2018-11-06", dtype="datetime64")
1893 x = np.ones(len(t))
1894
1895 fig, ax = plt.subplots()
1896 ax.plot(t, x)
1897
1898 ax.xaxis.set_major_locator(mpl.dates.DayLocator())
1899 ax.xaxis.set_major_formatter(mpl.dates.DateFormatter('\n%a'))
1900
1901 ax.xaxis.set_minor_locator(mpl.dates.HourLocator((0, 6, 12, 18)))
1902 ax.xaxis.set_minor_formatter(mpl.dates.DateFormatter('%H:%M'))
1903 # force there to be extra ticks
1904 ax.xaxis.get_minor_ticks(15)
1905 if remove_overlapping_locs is not None:
1906 ax.xaxis.remove_overlapping_locs = remove_overlapping_locs
1907
1908 # check that getter/setter exists
1909 current = ax.xaxis.remove_overlapping_locs
1910 assert (current == ax.xaxis.get_remove_overlapping_locs())
1911 plt.setp(ax.xaxis, remove_overlapping_locs=current)
1912 new = ax.xaxis.remove_overlapping_locs
1913 assert (new == ax.xaxis.remove_overlapping_locs)
1914
1915 # check that the accessors filter correctly
1916 # this is the method that does the actual filtering
1917 assert len(ax.xaxis.get_minorticklocs()) == expected_num
1918 # these three are derivative
1919 assert len(ax.xaxis.get_minor_ticks()) == expected_num
1920 assert len(ax.xaxis.get_minorticklabels()) == expected_num
1921 assert len(ax.xaxis.get_minorticklines()) == expected_num*2
1922
1923
1924@pytest.mark.parametrize('sub', [

Callers

nothing calls this directly

Calls 11

set_minor_locatorMethod · 0.80
set_minor_formatterMethod · 0.80
get_minorticklocsMethod · 0.80
get_minorticklabelsMethod · 0.80
get_minorticklinesMethod · 0.80
subplotsMethod · 0.45
plotMethod · 0.45
set_major_locatorMethod · 0.45
set_major_formatterMethod · 0.45
get_minor_ticksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…