-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Errorbar does not plot errorbars centered on the marker #3400
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
I can reproduce this in the gui Qt4 and Mac OSx backends. It does look correct in saved png and pdf files thou. Edit: This is with 1.4rc4 |
It persists in my saved png files. In fact, the images I uploaded were from a saved png. |
On ubuntu, using Qt4agg, the line appears also shifted but on the other side. When saving from the gui (or using import matplotlib as plt
plt.xlim((0.897, 1.103))
plt.errorbar([1],[1],[0.1],fmt='k^',capsize=5,capthick=2,ms=9,markerfacecolor='none',mew=2, label='a')
plt.legend()
plt.show() (Also, I don't understand why the marker is shown twice in the legend.) |
The legend normally shows two points connected by the line style used. You can customise that with the numpoints argument to legend |
IIRC, there was some work during SciPy 2013 to deal with positioning issues On Mon, Aug 25, 2014 at 10:17 AM, Jens H Nielsen notifications@github.com
|
The issue is this (and it's a tricky one to solve). matplotlib includes a feature called "pixel snapping" which helps to avoid fuzzy-looking anti-aliasing by aligning to pixels. When you have a line with a width that is an odd number of pixels, it is aligned to pixel centers. When you have a line with a width that is an even number of pixels, it is aligned to pixel edges. In this example, the line is an odd width (1), while the marker line is an even width (2). So their alignment is a half pixel different. How this is should probably work is that the alignment is determined by the line, and never by the marker. Unfortunately, as it stands now, the marker drawing doesn't know about the width of the line that it's associated with (only the width of the marker edge itself). So that will require some reorganization of code to get right. In the meantime, as a workaround: you can (a) set the marker edge width to the same as the line edge width or (b) output to any of the vector formats which do not have this snapping behavior (since something else ultimately does the rendering later). |
I get the same behavior using the same marker edge width and line width, so I don't accept that explanation. Upon inspection it is indeed the line and not the marker that is off. The marker aligns with the tickmarks, but the error line is 1 pixel off. |
I thought I tried to turn snapping off and it didn't make a difference. |
Which backend are you using? Also, which version of matplotlib. This might SVG, EPS and PDF are all vector formats that saves the raw vector data. It On Mon, Aug 25, 2014 at 12:42 PM, quovatis notifications@github.com wrote:
|
As was in my initial post, I'm using matplotlib 1.3.1 and MacOSX. I've tried various combinations of marker edge widths and line widths, and the problem persists in all combinations. |
I can reproduce this on master. |
Is this bug still relevant? I see it in 1.5.3 on my work machine. However, when saving the figure as PDF it is not there.... |
See #3400 (comment). I think this is due (as usual) to stamping -- looks like mpl_cairo does not display the issue (if snapping is turned off). |
Still present in 2.1. Tested macosx, wx, and tkagg backends, and it's present in all of them. Issue is not present in Cairo. |
Still an issue in 3.0.1 |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
This is pixel snapping - |
Using
errorbar
does not properly center the errorbar on the marker. See the following example and output. The issue persists in the legend as well. The errorbar is a few pixels off center and changing thelinewidth
does not solve the issue.snap
kwarg has no effect either. I have reproduced this using matplotlib 1.2.1 and 1.3.1 on Mac OSX 10.8.4.The text was updated successfully, but these errors were encountered: