()
| 614 | |
| 615 | |
| 616 | def test_contourf_legend_elements(): |
| 617 | from matplotlib.patches import Rectangle |
| 618 | x = np.arange(1, 10) |
| 619 | y = x.reshape(-1, 1) |
| 620 | h = x * y |
| 621 | |
| 622 | cs = plt.contourf(h, levels=[10, 30, 50], |
| 623 | colors=['#FFFF00', '#FF00FF', '#00FFFF'], |
| 624 | extend='both') |
| 625 | cs.cmap = cs.cmap.with_extremes(over='red', under='blue') |
| 626 | cs.changed() |
| 627 | artists, labels = cs.legend_elements() |
| 628 | assert labels == ['$x \\leq -1e+250s$', |
| 629 | '$10.0 < x \\leq 30.0$', |
| 630 | '$30.0 < x \\leq 50.0$', |
| 631 | '$x > 1e+250s$'] |
| 632 | expected_colors = ('blue', '#FFFF00', '#FF00FF', 'red') |
| 633 | assert all(isinstance(a, Rectangle) for a in artists) |
| 634 | assert all(same_color(a.get_facecolor(), c) |
| 635 | for a, c in zip(artists, expected_colors)) |
| 636 | |
| 637 | |
| 638 | def test_contour_legend_elements(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…