Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Custom marker created from vertex list scales wrong #1980

Copy link
Copy link
Closed
@vMeijin

Description

@vMeijin
Issue body actions

Hello,
I am new here and I dont know if this is the right place, but I found a slight misbehave, when creating a custom markerstyle. If you plot something, eg:

pyplot.plot([0,0], [1,1], markersize=5, marker=[[0,0], [0,1], [1, 1], [1,0]) # marker is a square with size 1

The marker has the same size as marker='s', but is not centered. If you use

pyplot.plot([0,0], [1,1], markersize=5, marker=[[-0.5,-0.5], [-0.5,0.5], [0.5,0.5]], [0.5,-0.5]) # still square of size 1

the resulting marker is centered but twice the size. The problem is the the function MarkerStyle._set_custom_marker in markers.py:

def _set_custom_marker(self, path):
    verts = path.vertices
    rescale = max(np.max(np.abs(verts[:,0])), np.max(np.abs(verts[:,1])))
    self._transform = Affine2D().scale(1.0 / rescale)
    self._path = path

It rescales the given vertices, but considers only the max xy values, which results in twice. the size A solution could be to change the rescale factor to:

x, y = verts[:,0], verts[:,1]
rescale = max(abs(np.max(x) - np.min(x)), abs(np.max(y) - np.min(y)))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.