MCPcopy
hub / github.com/pandas-dev/pandas / _check_legend_labels

Function _check_legend_labels

pandas/tests/plotting/common.py:23–44  ·  view source on GitHub ↗

Check each axes has expected legend labels Parameters ---------- axes : matplotlib Axes object, or its list-like labels : list-like expected legend labels visible : bool expected legend visibility. labels are checked only when visible is True

(axes, labels=None, visible=True)

Source from the content-addressed store, hash-verified

21
22
23def _check_legend_labels(axes, labels=None, visible=True):
24 """
25 Check each axes has expected legend labels
26
27 Parameters
28 ----------
29 axes : matplotlib Axes object, or its list-like
30 labels : list-like
31 expected legend labels
32 visible : bool
33 expected legend visibility. labels are checked only when visible is
34 True
35 """
36 if visible and (labels is None):
37 raise ValueError("labels must be specified when visible is True")
38 axes = _flatten_visible(axes)
39 for ax in axes:
40 if visible:
41 assert ax.get_legend() is not None
42 _check_text_labels(ax.get_legend().get_texts(), labels)
43 else:
44 assert ax.get_legend() is None
45
46
47def _check_legend_marker(ax, expected_markers=None, visible=True):

Calls 2

_flatten_visibleFunction · 0.85
_check_text_labelsFunction · 0.85