Skip to content

Support markers from Paths that consist of one line segment #10632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,18 @@ def set_marker(self, marker):
if (isinstance(marker, np.ndarray) and marker.ndim == 2 and
marker.shape[1] == 2):
self._marker_function = self._set_vertices
elif (isinstance(marker, six.string_types)
and cbook.is_math_text(marker)):
self._marker_function = self._set_mathtext_path
elif isinstance(marker, Path):
self._marker_function = self._set_path_marker
elif (isinstance(marker, Sized) and len(marker) in (2, 3) and
marker[1] in (0, 1, 2, 3)):
self._marker_function = self._set_tuple_marker
elif (not isinstance(marker, (np.ndarray, list)) and
marker in self.markers):
self._marker_function = getattr(
self, '_set_' + self.markers[marker])
elif (isinstance(marker, six.string_types)
and cbook.is_math_text(marker)):
self._marker_function = self._set_mathtext_path
elif isinstance(marker, Path):
self._marker_function = self._set_path_marker
else:
try:
Path(marker)
Expand Down
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_marker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
from matplotlib import markers
from matplotlib.path import Path

import pytest

Expand All @@ -18,3 +19,10 @@ def test_markers_invalid():
# Checking this does fail.
with pytest.raises(ValueError):
marker_style.set_marker(mrk_array)


def test_marker_path():
marker_style = markers.MarkerStyle()
path = Path([[0, 0], [1, 0]], [Path.MOVETO, Path.LINETO])
# Checking this doesn't fail.
marker_style.set_marker(path)