terrorbar.m: Error bars with controlled widths post-R2014b

버전 1.0.0.0 (10.4 KB) 작성자: Trevor Agus
Draws error bars (as line objects), allowing you to specify the width of the horizontal bars
다운로드 수: 1.1K
업데이트 날짜: 2015/8/2

라이선스 보기

It is a known problem that the built-in "errorbar.m" sets the width of the error bars horizontal lines automatically (see http://www.mathworks.com/matlabcentral/answers/166285-control-errorbar-width-in-matlab-r2014b), meaning that different graphs or lines might have inconsistently formatted error bars. Up to R2014a, there was a hack to get around this, but it doesn't work post R2014b.
This program draws error bars as specified, simply using the "plot" function to draw lines of appropriate size. You can specify their width relative to the x-axis size ("units") or in absolute terms ("centi", "inches", etc.). You can use it much like errorbar, but with extra terms, e.g.
>> h=terrorbar([1 2 3],[2 4 6],[.5 .7 .9],[.5 .7 .9],0.25,'centi');
i.e.
>> h=terrorbar(xvalues,yvalues,lowererrorrbarheight,uppererrorbarheight,errorbarwidth,widthunits);
...and sensible variants of this also work (e.g. omitting the uppererrorbarheight gets you symmetric error bars).

NB This function doesn't draw a line through the points, nor bars for a bar chart. Use your usual other program to do that. Using "hold on" you can generally draw on the error bars before or after, depending on whether you want the error bars to be underneath the markers (normal for line graphs) or on to of them (normal for bar charts).

If needed you can tweak the error bar widths after, using this same function:
>> terrorbar(h,0.5,'centi')
or
>> terrorbar(h,0.5) %assumes same units as before
or
>> terrorbar(0.5,'centi') %is applied to all error bars in the current figure.

If you resize the figure after, the errorbars will cunningly update their width appropriately (e.g. if you specified their width in centimetres, they will remain as wide). However, if you update the axis width, the error bars may not behave as you want. You can always reinforce the original size requests by running terrorbar, even without parameters:
>> terrorbar

Known problems:

* Not yet programmed for use with a logarithmic x-axis

* May get stuck in a recursive loop if the error bars are very wide compared to everything else. But then that's a rather unlikely scenario...

* Not yet thoroughly tested, except for what I wanted it to do -- let me know if you find another bug.

인용 양식

Trevor Agus (2024). terrorbar.m: Error bars with controlled widths post-R2014b (https://www.mathworks.com/matlabcentral/fileexchange/52367-terrorbar-m-error-bars-with-controlled-widths-post-r2014b), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2014b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Errorbars에 대해 자세히 알아보기
도움

도움 준 파일: superbar

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0

minor editing of text formatting