-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
marker edges overlap with marker #13360
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
1. Overlapping not an issueThe line is drawn along the edge of the marker. It's common practice in vector graphics that half of the line width is to either side of the drawing path. The "ring" is the overlaid color of the filled area and the edge. This is also standard behavior see e.g. this red circle with a semi-transparent green edge produced in inkscape: 2. Sizes are incorrectWhat actually does not work correctly are the sizes, e.g.
|
I see, that makes sense. I agree that the sizes are incorrect. In inkscape if the stroke width is 1/4 of the object size that stroke overlays half on the object and half off thus adding exactly its width to the objects width (unlike in matplotlib which currently adds |
That's because your example is using |
Note: the actual sizes are rather undocumented except if you look at the table here (which is really just an implicit thing, and not explicitly spelled out.) |
@QuLogic So I see now that if using |
The
As for the reason for the factor of 0.5, I can only speculate: If you specify I think anyone is welcome to document the factor of 0.5 in the marker documentation. |
Just out of curiosity: why should it be good that the edge overlaps the marker filling by half? An edge is an edge, and the current behavior is counter intuitive, especially if the edge color is the same as the fill color. I know that this is a very old feature and users have gotten used to it. Adding a bit of control could not harm, though. How about a parameter |
As written above #13360 (comment), the edge overlapping the marker half is common practice. It‘s also much simpler to perform: The edge is a line drawn at the shape coordinates. If you put the line to the inner or outer side of the shape, it‘s point coordinates become dependent on the line width and even worse on the angles of the connecting segments. And even if done correctly, there may be interpolation artifacts at the interface if the body and the line do not overlap. |
Closing as intended behavior. |
Plotting the points twice once without edge and once without face is a workaround: import matplotlib.pyplot as plt
plt.figure()
plt.plot(0, 'og', ms=100, mew=10, alpha=0.5)
plt.plot(1, 'og', ms=100, mew=10, alpha=0.5, mec='None')
plt.plot(1, 'og', ms=100-10, mew=10, alpha=0.5, mfc='none')
plt.show() |
Another option is to only make the face color transparent and keep the edge solid. This is likely acceptable appearance in many cases:
|
Bug report
Bug summary
Marker edge overlaps with marker and the edge appears to be double the width specified. This becomes obvious when you use alpha transparency and a very larger point marker with a large edge width or in the case where I noticed it a small figure (about 2 inches wide) with the default rcParams.
Code for reproduction
Case 1: very large point with a large edge width
Case 2: very small figure with default rcParams: markersize = 8, markeredgewidth=1.0
Actual outcome


In this figure I have markersize=200 and markeredgewith=50. There is an ugly ring and it looks as if the marker edges are two times wider (100 instead of 50) than I asked.
Now in this figure I have markersize=200 and markeredgewidth=99. There is a single pixel in the center that is faded blue thus the markeredges are definitely twice what I asked for. If I set the markeredgewith to 100 I get a solid core.
Expected outcome

I would expect that the marker edge would line up perfectly with the marker core. In this plot I set markersize to 300 (200 plus 2*50 edges) to get the same size as the original without the ugly ring.
Matplotlib version
The text was updated successfully, but these errors were encountered: