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

4 次查看(过去 30 天)
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?

采纳的回答

Amy
Amy 2017-10-26
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 个评论
Amy
Amy 2017-10-26
If it isn't important that the figure be saved as a vector file, have you tried '-opengl' as the renderer instead?
Luwei Ge
Luwei Ge 2017-10-26
编辑:Luwei Ge 2017-10-26
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..

请先登录,再进行评论。

更多回答(1 个)

Jens De Pelsmaeker
Jens De Pelsmaeker 2017-11-21

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 个评论
Amy
Amy 2017-12-4
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Errorbars 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by