Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix for marker verts bug #7809

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 3 commits into from
Jan 30, 2017
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: 6 additions & 4 deletions lib/matplotlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,14 @@ def get_marker(self):
return self._marker

def set_marker(self, marker):
if (isinstance(marker, Sized) and len(marker) in (2, 3) and
if (isinstance(marker, np.ndarray) and marker.ndim == 2 and
marker.shape[1] == 2):
self._marker_function = self._set_vertices
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 isinstance(marker, np.ndarray):
self._marker_function = self._set_vertices
elif not isinstance(marker, list) and marker in self.markers:
elif (not isinstance(marker, (np.ndarray, list)) and
marker in self.markers):
self._marker_function = getattr(
self, '_set_' + self.markers[marker])
elif is_string_like(marker) and is_math_text(marker):
Expand Down
20 changes: 20 additions & 0 deletions lib/matplotlib/tests/test_marker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import numpy as np
from matplotlib import markers

import pytest


def test_markers_valid():
marker_style = markers.MarkerStyle()
mrk_array = np.array([[-0.5, 0],
[0.5, 0]])
# Checking this doesn't fail.
marker_style.set_marker(mrk_array)


def test_markers_invalid():
marker_style = markers.MarkerStyle()
mrk_array = np.array([[-0.5, 0, 1, 2, 3]])
# Checking this does fail.
with pytest.raises(ValueError):
marker_style.set_marker(mrk_array)