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

Function test_pie_label_auto_align

lib/matplotlib/tests/test_axes.py:6891–6913  ·  view source on GitHub ↗
(distance, rotate)

Source from the content-addressed store, hash-verified

6889@pytest.mark.parametrize('distance', [0.6, 1.1])
6890@pytest.mark.parametrize('rotate', [False, True])
6891def test_pie_label_auto_align(distance, rotate):
6892 fig, ax = plt.subplots()
6893 pie = ax.pie([1, 1], startangle=45)
6894
6895 texts = ax.pie_label(
6896 pie, ['spam', 'eggs'], distance=distance, rotate=rotate, alignment='auto')
6897
6898 if distance < 1:
6899 for text in texts:
6900 # labels within the pie should be centered
6901 assert text.get_horizontalalignment() == 'center'
6902 assert text.get_verticalalignment() == 'center'
6903
6904 else:
6905 # labels outside the pie should be aligned away from it
6906 h_expected = ['right', 'left']
6907 v_expected = ['bottom', 'top']
6908 for text, h_align, v_align in zip(texts, h_expected, v_expected):
6909 assert text.get_horizontalalignment() == h_align
6910 if rotate:
6911 assert text.get_verticalalignment() == v_align
6912 else:
6913 assert text.get_verticalalignment() == 'center'
6914
6915
6916def test_pie_label_fail():

Callers

nothing calls this directly

Calls 5

pieMethod · 0.80
pie_labelMethod · 0.80
get_verticalalignmentMethod · 0.80
subplotsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…