How can I make the errorbars vertically centered around the markers? I am using Matlab2016b.

For data x, y and e, I simply used
errorbar(x,y,e,'ro');
and saved the figure as eps or pdf. In the resulting figure, the errorbars are always not perfectly centered around the markers. Below is the example.
I am wondering if there is any way to adjust the position the those errorbars?

 Accepted Answer

Hi Luwei,
Unfortunately, what you are seeing is a bug in R2016b that the relevant team is aware of.
Is the marker offset visible even before you save the figure?
Make sure the 'PaperPositionMode' of the figure to is set 'auto' (see this page for more details on figure properties).
Also, instead of using 'File->Save as...' to save the figure, try either the saveas or print functions.

3 Comments

Thanks for your reply, Amy!
Unfortunately, the offset is visible before I saved figures.
I have never modified the 'PaperPositionMode' setting so I believe it is always in 'auto' mode.
Speaking of how to save the files, I have been using print often with '-depsc' option and '-painters' as the renderer.
Actually I also tried 2017b (or 2017a, I don't quite remember) and this problem was there as well. Hope this can be fixed in later releases. Thanks again.
If it isn't important that the figure be saved as a vector file, have you tried '-opengl' as the renderer instead?
I just tried and please see the attached screenshot as the result. I have to say this offset is not always present on all data points. The issue gets more significant typically when the line width is set to be bigger.
Meanwhile, for what I am working on, vector images are almost always preferable..

Sign in to comment.

More Answers (1)

Hi Lewei and Amy,

I am currently struggling with the same problem, trying to look for a solution, which is how I ended up on this thread. I am using MATLAB 2017b prerelease version.

Amy's suggestion of changing the PaperPositionMode to 'auto' has fixed the problem for me in matlab itself, before saving, but when saving to eps using 'saveas(gcf, ,'epsc'), the figures look like the misaligned original below, where the green dots are clearly slightly offset to the left of the vertical lines instead of properly centered:

Sadly, this forms quite a problem for me (and an urgent one), as I am currently using matlab to create several figures of this type to be included in the manuscript for the defense of my PhD, due in a matter of weeks. Everything is in vector format as the manuscript is written in LaTeX.

Amy, seeing that you mentioned this is caused by a bug, is there any solution in sight or should I look for a different method of creating my figures?

Many thanks in advance, Jens

1 Comment

Hi, sorry for the delay in getting back to you. When 'PaperPositionMode' is set to auto, the printed generated output should preserve the onscreen layout.
After setting 'PaperPositionMode' and before printing, make sure that the onscreen figure is sized appropriately for the content. Note this may require resizing the docked figure container, or undocking the figure and then resizing that.
If you are still running into this issue, consider opening a technical support case about it here.

Sign in to comment.

Asked:

on 23 Oct 2017

Commented:

Amy
on 4 Dec 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!