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

Function test_radial_locator_wrapping

lib/matplotlib/tests/test_polar.py:578–615  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

576
577
578def test_radial_locator_wrapping():
579 # Check that the locator is always wrapped inside a RadialLocator
580 # and that RaidialAxis.isDefault_majloc is set correctly.
581 fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
582 assert ax.yaxis.isDefault_majloc
583 assert isinstance(ax.yaxis.get_major_locator(), RadialLocator)
584
585 # set an explicit locator
586 locator = mticker.MaxNLocator(3)
587 ax.yaxis.set_major_locator(locator)
588 assert not ax.yaxis.isDefault_majloc
589 assert isinstance(ax.yaxis.get_major_locator(), RadialLocator)
590 assert ax.yaxis.get_major_locator().base is locator
591
592 ax.clear() # reset to the default locator
593 assert ax.yaxis.isDefault_majloc
594 assert isinstance(ax.yaxis.get_major_locator(), RadialLocator)
595
596 ax.set_rticks([0, 1, 2, 3]) # implicitly sets a FixedLocator
597 assert not ax.yaxis.isDefault_majloc # because of the fixed ticks
598 assert isinstance(ax.yaxis.get_major_locator(), RadialLocator)
599 assert isinstance(ax.yaxis.get_major_locator().base, mticker.FixedLocator)
600
601 ax.clear()
602
603 ax.set_rgrids([0, 1, 2, 3]) # implicitly sets a FixedLocator
604 assert not ax.yaxis.isDefault_majloc # because of the fixed ticks
605 assert isinstance(ax.yaxis.get_major_locator(), RadialLocator)
606 assert isinstance(ax.yaxis.get_major_locator().base, mticker.FixedLocator)
607
608 ax.clear()
609
610 ax.set_yscale("log") # implicitly sets a LogLocator
611 # Note that the LogLocator is still considered the default locator
612 # for the log scale
613 assert ax.yaxis.isDefault_majloc
614 assert isinstance(ax.yaxis.get_major_locator(), RadialLocator)
615 assert isinstance(ax.yaxis.get_major_locator().base, mticker.LogLocator)
616
617
618def test_set_rticks_ticklabels_no_warning():

Callers

nothing calls this directly

Calls 7

get_major_locatorMethod · 0.80
set_rticksMethod · 0.80
set_rgridsMethod · 0.80
subplotsMethod · 0.45
set_major_locatorMethod · 0.45
clearMethod · 0.45
set_yscaleMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…