|
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 |
|
@@ -230,6 +230,34 @@ def test_basic_annotate():
|
230 | 230 | xytext=(3, 3), textcoords='offset points')
|
231 | 231 |
|
232 | 232 |
|
| 233 | +@image_comparison(baseline_images=['arrow_simple'], |
| 234 | + extensions=['png'], remove_text=True) |
| 235 | +def test_arrow_simple(): |
| 236 | + # Simple image test for ax.arrow |
| 237 | + # kwargs that take discrete values |
| 238 | + length_includes_head = (True, False) |
| 239 | + shape = ('full', 'left', 'right') |
| 240 | + head_starts_at_zero = (True, False) |
| 241 | + # Create outer product of values |
| 242 | + kwargs = list(product(length_includes_head, shape, head_starts_at_zero)) |
| 243 | + |
| 244 | + fig, axs = plt.subplots(3, 4) |
| 245 | + for i, (ax, kwarg) in enumerate(zip(axs.flatten(), kwargs)): |
| 246 | + ax.set_xlim(-2, 2) |
| 247 | + ax.set_ylim(-2, 2) |
| 248 | + # Unpack kwargs |
| 249 | + (length_includes_head, shape, head_starts_at_zero) = kwarg |
| 250 | + theta = 2 * np.pi * i / 12 |
| 251 | + # Draw arrow |
| 252 | + ax.arrow(0, 0, np.sin(theta), np.cos(theta), |
| 253 | + width=theta/100, |
| 254 | + length_includes_head=length_includes_head, |
| 255 | + shape=shape, |
| 256 | + head_starts_at_zero=head_starts_at_zero, |
| 257 | + head_width=theta / 10, |
| 258 | + head_length=theta / 10) |
| 259 | + |
| 260 | + |
233 | 261 | @image_comparison(baseline_images=['polar_axes'])
|
234 | 262 | def test_polar_annotations():
|
235 | 263 | # you can specify the xypoint and the xytext in different
|
|
0 commit comments