-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Custom marker created from vertex list scales wrong #1980
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
Comments
Hi @vMeijin, It doesn't seem to say it anywhere, but I think your marker should be in the range Does that answer your question? If so, given what you now know, do you think the documentation could be improved? The documentation for this part of matplotlib can be found https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/markers.py#L48 and we would really value any contribution to make it better. Cheers, |
Hello, rescale = max(np.max(np.abs(verts[:,0])), np.max(np.abs(verts[:,1]))) It only considers the absolute max of the x/y (which would be 1 in this case) for rescale. Here is a small example which shows the difference: from matplotlib import pyplot
import numpy
pyplot.plot([0, 1, 2], [0, 1, 2], marker="s", markersize=20)
pyplot.plot([0, 1, 2 ], [1, 2, 3], marker=numpy.array([[-1, -1], [-1, 1], [1, 1], [1, -1]]), markersize=20)
pyplot.show() |
BUG: Fixes custom path marker sizing Closes #1980 Closes
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:
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)))
The text was updated successfully, but these errors were encountered: