Skip to content

Commit

Permalink
Merge pull request #7809 from lkilcher/marker_verts_bug
Browse files Browse the repository at this point in the history
Fix for marker verts bug
  • Loading branch information
dstansby committed Jan 31, 2017
1 parent fbe562c commit 98a9347
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/matplotlib/markers.py
Expand Up @@ -246,12 +246,14 @@ def get_marker(self):
return self._marker

def set_marker(self, marker):
if (iterable(marker) 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 (iterable(marker) 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
@@ -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)

0 comments on commit 98a9347

Please sign in to comment.