|
| 1 | +import pytest |
1 | 2 | import matplotlib.pyplot as plt |
2 | 3 | from matplotlib.testing.decorators import image_comparison |
3 | 4 | import matplotlib.patches as mpatches |
@@ -133,3 +134,34 @@ def test_arrow_styles(): |
133 | 134 | arrowstyle=stylename, |
134 | 135 | mutation_scale=25) |
135 | 136 | ax.add_patch(patch) |
| 137 | + |
| 138 | + |
| 139 | +@image_comparison(baseline_images=['connection_styles'], extensions=['png'], |
| 140 | + style='mpl20', remove_text=True) |
| 141 | +def test_connection_styles(): |
| 142 | + styles = mpatches.ConnectionStyle.get_styles() |
| 143 | + |
| 144 | + n = len(styles) |
| 145 | + fig, ax = plt.subplots(figsize=(6, 10)) |
| 146 | + ax.set_xlim(0, 1) |
| 147 | + ax.set_ylim(-1, n) |
| 148 | + |
| 149 | + for i, stylename in enumerate(sorted(styles)): |
| 150 | + patch = mpatches.FancyArrowPatch((0.1, i), (0.8, i + 0.5), |
| 151 | + arrowstyle="->", |
| 152 | + connectionstyle=stylename, |
| 153 | + mutation_scale=25) |
| 154 | + ax.add_patch(patch) |
| 155 | + |
| 156 | + |
| 157 | +def test_invalid_intersection(): |
| 158 | + conn_style_1 = mpatches.ConnectionStyle.Angle3(angleA=20, angleB=200) |
| 159 | + p1 = mpatches.FancyArrowPatch((.2, .2), (.5, .5), |
| 160 | + connectionstyle=conn_style_1) |
| 161 | + with pytest.raises(ValueError): |
| 162 | + plt.gca().add_patch(p1) |
| 163 | + |
| 164 | + conn_style_2 = mpatches.ConnectionStyle.Angle3(angleA=20, angleB=199.9) |
| 165 | + p2 = mpatches.FancyArrowPatch((.2, .2), (.5, .5), |
| 166 | + connectionstyle=conn_style_2) |
| 167 | + plt.gca().add_patch(p2) |
0 commit comments