|
7 | 7 |
|
8 | 8 | from cycler import cycler |
9 | 9 | import numpy as np |
| 10 | +from numpy.testing import assert_array_equal |
10 | 11 | import pytest |
11 | 12 |
|
12 | 13 | import matplotlib |
13 | 14 | import matplotlib.lines as mlines |
| 15 | +from matplotlib.markers import MarkerStyle |
| 16 | +from matplotlib.path import Path |
14 | 17 | import matplotlib.pyplot as plt |
15 | 18 | from matplotlib.testing.decorators import image_comparison, check_figures_equal |
16 | 19 |
|
@@ -194,3 +197,23 @@ def test_nan_is_sorted(): |
194 | 197 | def test_step_markers(fig_test, fig_ref): |
195 | 198 | fig_test.subplots().step([0, 1], "-o") |
196 | 199 | fig_ref.subplots().plot([0, 0, 1], [0, 1, 1], "-o", markevery=[0, 2]) |
| 200 | + |
| 201 | + |
| 202 | +def test_marker_as_markerstyle(): |
| 203 | + fig, ax = plt.subplots() |
| 204 | + line, = ax.plot([2, 4, 3], marker=MarkerStyle("D")) |
| 205 | + fig.canvas.draw() |
| 206 | + assert line.get_marker() == "D" |
| 207 | + |
| 208 | + # continue with smoke tests: |
| 209 | + line.set_marker("s") |
| 210 | + fig.canvas.draw() |
| 211 | + line.set_marker(MarkerStyle("o")) |
| 212 | + fig.canvas.draw() |
| 213 | + # test Path roundtrip |
| 214 | + triangle1 = Path([[-1., -1.], [1., -1.], [0., 2.], [0., 0.]], closed=True) |
| 215 | + line2, = ax.plot([1, 3, 2], marker=MarkerStyle(triangle1), ms=22) |
| 216 | + line3, = ax.plot([0, 2, 1], marker=triangle1, ms=22) |
| 217 | + |
| 218 | + assert_array_equal(line2.get_marker().vertices, triangle1.vertices) |
| 219 | + assert_array_equal(line3.get_marker().vertices, triangle1.vertices) |
0 commit comments