|
3 | 3 |
|
4 | 4 | import six
|
5 | 5 | from six.moves import xrange
|
6 |
| -from itertools import chain |
| 6 | +from itertools import chain, product |
7 | 7 | from distutils.version import LooseVersion
|
8 | 8 | import io
|
9 | 9 |
|
@@ -263,6 +263,34 @@ def test_basic_annotate():
|
263 | 263 | xytext=(3, 3), textcoords='offset points')
|
264 | 264 |
|
265 | 265 |
|
| 266 | +@image_comparison(baseline_images=['arrow_simple'], |
| 267 | + extensions=['png'], remove_text=True) |
| 268 | +def test_arrow_simple(): |
| 269 | + # Simple image test for ax.arrow |
| 270 | + # kwargs that take discrete values |
| 271 | + length_includes_head = (True, False) |
| 272 | + shape = ('full', 'left', 'right') |
| 273 | + head_starts_at_zero = (True, False) |
| 274 | + # Create outer product of values |
| 275 | + kwargs = list(product(length_includes_head, shape, head_starts_at_zero)) |
| 276 | + |
| 277 | + fig, axs = plt.subplots(3, 4) |
| 278 | + for i, (ax, kwarg) in enumerate(zip(axs.flatten(), kwargs)): |
| 279 | + ax.set_xlim(-2, 2) |
| 280 | + ax.set_ylim(-2, 2) |
| 281 | + # Unpack kwargs |
| 282 | + (length_includes_head, shape, head_starts_at_zero) = kwarg |
| 283 | + theta = 2 * np.pi * i / 12 |
| 284 | + # Draw arrow |
| 285 | + ax.arrow(0, 0, np.sin(theta), np.cos(theta), |
| 286 | + width=theta/100, |
| 287 | + length_includes_head=length_includes_head, |
| 288 | + shape=shape, |
| 289 | + head_starts_at_zero=head_starts_at_zero, |
| 290 | + head_width=theta / 10, |
| 291 | + head_length=theta / 10) |
| 292 | + |
| 293 | + |
266 | 294 | def test_annotate_default_arrow():
|
267 | 295 | # Check that we can make an annotation arrow with only default properties.
|
268 | 296 | fig, ax = plt.subplots()
|
|
0 commit comments