ERRORBARXY is a function to generate errorbars on both x and y axes
with specified errors modified from codes written by Nils Sjöberg
(http://www.mathworks.com/matlabcentral/fileexchange/5444-xyerrorbar)
errorbarxy(x, y, lerrx, uerrx, lerry, uerry) plots the data with errorbars on both
x and y axes with error bars [x-lerrx, x+uerrx] and [y-lerry, y+uerry]. If there is
no error on one axis, set corresponding lower and upper bounds to [].
errorbarxy(x, y, errx, erry) plots the data with errorbars on both x and
y axes with error bars [x-errx, x+errx] and [y-erry, y+erry]. If there
is no error on one axis, set corresponding errors to [].
errorbarxy(..., S) plots data as well as errorbars using specified
character strings. S is a cell array of 3 element, {sData, cEBx, cEBy},
where sData specifies the format of main plot, cEBx specifies the
color of errorbars along x axis and cEBy specifies the color of
errorbars along y axis.
errorbarxy(AX,...) plots into AX instead of GCA.
H = errorbar(...) returns a vector of errorbarseries handles in H,
within which the first element is the handle to the main data plot and
the remaining elements are handles to the rest errorbars.
H is organized as follows:
H.hMain is the handle of the main plot
H.hErrorbar is a Nx6 matrix containing handles for all error bar lines,
where N is the number of samples. For each sample, 6
errorbar handles are saved in such an order:
[Horizontal bar, H bar left cap, H bar right cap,
Vertical bar, V bar lower cap, V bar upper cap]
For example
x = 1:10;
xe = 0.5*ones(size(x));
y = sin(x);
ye = std(y)*ones(size(x));
H=errorbarxy(x,y,xe,ye,{'ko-', 'b', 'r'});
draws symmetric error bars on both x and y axes.
NOTE: errorbars are excluded from legend display. If you need to
include errorbars in legend display, do the followings:
H=errorbarxy(...);
arrayfun(@(d) set(get(get(d,'Annotation'),'LegendInformation'),...
'IconDisplayStyle','on'), H(2:end)); % include errorbars
hEB=hggroup;
set(H(2:end),'Parent',hEB);
set(get(get(hEB,'Annotation'),'LegendInformation'),...
'IconDisplayStyle','on'); % include errorbars in legend as a group.
legend('Main plot', 'Error bars');
Developed under Matlab version 7.10.0.499 (R2010a)
Created by Qi An
anqi2000@gmail.com
引用格式
Qi An (2024). Plot data with error bars on both x and y axes (https://www.mathworks.com/matlabcentral/fileexchange/40221-plot-data-with-error-bars-on-both-x-and-y-axes), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
- MATLAB > Graphics > 2-D and 3-D Plots > Line Plots > Errorbars >
- AI and Statistics > Statistics and Machine Learning Toolbox > Descriptive Statistics and Visualization > Statistical Visualization > Box Plots >
标签
致谢
启发作品: errbar, errorbarxy, superbar, High-Throughput, Algorithmic Determination of Nanoparticle Structure from Electron Microscopy Images
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.81.0.0 | The code will "remember" if the axis is set to be "HOLD ON".
|
||
1.8.0.0 | Fixed a bug when some of errx/erry/lerrx/uerrx/lerry/uerry are not specified the code will error out. |
||
1.7.0.0 | Check for formatting string. Fixed a bug when specifying axis to plot. |
||
1.6.0.0 | Allow customization on main plot |
||
1.5.0.0 | Reorganize the output handle structure. |
||
1.4.0.0 | Fixed a bug when outputting figure handles. |
||
1.3.0.0 | Fixed a bug in errorbar cap display. |
||
1.2.0.0 | Excluded errorbars from legend display. |
||
1.1.0.0 | Added support to plot on specified axes; Added support to specify color of plots and errorbars; Output avector of errbar series handles; Fixed a couple of minor bugs. |
||
1.0.0.0 |