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)
| 21 | |
| 22 | |
| 23 | def _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 | |
| 47 | def _check_legend_marker(ax, expected_markers=None, visible=True): |