MATLAB Answers

David
0

Errorbar remove tee, 2015

David
さんによって質問されました 2015 年 4 月 11 日
最新アクティビティ David
さんによって コメントされました 2015 年 6 月 5 日
Hi,
I very very strongly dislike the horizontal bars on errorbar plots. They don't scale properly when you zoom in, and they just clutter up plots. I don't have admin privileges on my machine so I can't modify the errorbar.m file itself. Before 2015 I could find handles to the Data for the tees and remove them, but it doesn't work anymore. In 2015 they seem to have changed the object structure for graphics objects.
Has anyone figured out how to remove the tees yet in Matlab 2015?
Thanks, Dave

  0 件のコメント

サインイン to comment.

3 件の回答

Star Strider
回答者: Star Strider
2015 年 4 月 11 日
 採用された回答

You can’t eliminate the terminal crossbars, but you can create your own error bars without the terminal crossbars:
N = 20;
x = linspace(0, 2*pi, N); % Create Data
y = sin(x).^2; % Create Data
erbar = randn(1, N); % Create Error Bars
figure(1)
plot(x, y)
hold on
plot([x; x], [y-erbar; y+erbar], '-r')
hold off
grid
This is likely as good at it gets until MATLAB incorporates an option for them.

  3 件のコメント

David
2015 年 4 月 12 日
Only downside is the legend gets destroyed with an entry for every errorbar :(. Matlab, please write an errorbar function soon with a few sensible options please!!
Star Strider
2015 年 4 月 12 日
I hadn’t considered the legend, since I didn’t use it in that code. I don’t know what you’re plotting or the problem you are having (since legend('Data', '95% Error') works for me without problems when appended to the end of the code in my Answer).
Putting the error bar plot last would allow you to exclude them from the legend if you wanted to.
David
2015 年 6 月 5 日
I like to give a 'DisplayName' tag to things I plot, so that I can copy traces around to different plots without forgetting when the data was taken and under what conditions, and then use legend('show') to automatically generate the legend based on the 'DisplayName' 's of all things that have been plotted. This is what doesn't work anymore with this technique

サインイン to comment.


Chad Greene
回答者: Chad Greene
2015 年 4 月 11 日

I've run into this problem often enough that this post finally inspired me to turn it into a function. The end lines generated by Matlab's built-in errorbar are often larger than the data itself, creating a cluttered plot that draws the focus away from the data.
Here's my errbar function if you're interested.

  1 件のコメント

David
2015 年 6 月 5 日
errbar is an awesome function, thanks Chad. I may see if I can find a way to get the errbars not to show up individually in the legend produced by calling legend('show') which would seal the deal for me.

サインイン to comment.


David
回答者: David
2015 年 4 月 11 日

Wow that's awesome. Thanks!

  1 件のコメント

Star Strider
2015 年 4 月 11 日
My pleasure!
I had this same problem myself, so that was test code for the idea.

サインイン to comment.



Translated by