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

Skip to content

set_marker(Path) is broken #10920

Closed
Closed
@alchayward

Description

@alchayward

Bug report

Bug summary

When a mpl.path.Path() is supplied to markers.MarkerStyle.set_marker we get a type error. This is due to the Path class being a Sized instance, since it implements len, and this is the property used to determine if set_marker was passed a set of verts (list of (x,y) pairs).

Code for reproduction

import matplotlib as mpl
import scipy as sp
xs = sp.linspace(0,1,20)
ys = xs + 0.1*sp.rand((20))-0.05
fig, ax = mpl.subplots(1,1)
ax.plot(xs,ys,marker=mpl.path.Path([[0,0],[1,1]]))

Actual outcome

/anaconda3/envs/physics/lib/python3.6/site-packages/matplotlib/markers.py in set_marker(self, marker)
    254             self._marker_function = self._set_vertices
    255         elif (isinstance(marker, Sized) and len(marker) in (2, 3) and
--> 256                 marker[1] in (0, 1, 2, 3)):
    257             self._marker_function = self._set_tuple_marker
    258         elif (not isinstance(marker, (np.ndarray, list)) and

TypeError: 'Path' object does not support indexing

Expected outcome

Should set the marker to the supplied path
Matplotlib version

  • Operating system: MacOSX
  • Matplotlib version: '2.1.2'
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: '3.6.4'
conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions