Skip to content

Commit 79fb398

Browse files
authored
Merge pull request #10632 from lpsinger/short-marker-path
Support markers from Paths that consist of one line segment
2 parents 71b7076 + 82f8672 commit 79fb398

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/matplotlib/markers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,18 @@ def set_marker(self, marker):
251251
if (isinstance(marker, np.ndarray) and marker.ndim == 2 and
252252
marker.shape[1] == 2):
253253
self._marker_function = self._set_vertices
254+
elif (isinstance(marker, six.string_types)
255+
and cbook.is_math_text(marker)):
256+
self._marker_function = self._set_mathtext_path
257+
elif isinstance(marker, Path):
258+
self._marker_function = self._set_path_marker
254259
elif (isinstance(marker, Sized) and len(marker) in (2, 3) and
255260
marker[1] in (0, 1, 2, 3)):
256261
self._marker_function = self._set_tuple_marker
257262
elif (not isinstance(marker, (np.ndarray, list)) and
258263
marker in self.markers):
259264
self._marker_function = getattr(
260265
self, '_set_' + self.markers[marker])
261-
elif (isinstance(marker, six.string_types)
262-
and cbook.is_math_text(marker)):
263-
self._marker_function = self._set_mathtext_path
264-
elif isinstance(marker, Path):
265-
self._marker_function = self._set_path_marker
266266
else:
267267
try:
268268
Path(marker)

lib/matplotlib/tests/test_marker.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
from matplotlib import markers
3+
from matplotlib.path import Path
34

45
import pytest
56

@@ -18,3 +19,10 @@ def test_markers_invalid():
1819
# Checking this does fail.
1920
with pytest.raises(ValueError):
2021
marker_style.set_marker(mrk_array)
22+
23+
24+
def test_marker_path():
25+
marker_style = markers.MarkerStyle()
26+
path = Path([[0, 0], [1, 0]], [Path.MOVETO, Path.LINETO])
27+
# Checking this doesn't fail.
28+
marker_style.set_marker(path)

0 commit comments

Comments
 (0)