4.0

4.0 | 1 rating Rate this file 9 Downloads (last 30 days) File Size: 6.08 KB File ID: #10843
image thumbnail

errorfill

by Peder Axensten

 

23 Apr 2006 (Updated 26 Apr 2006)

Use this function to draw a curve and its areas of confidence.

| Watch this File

File Information
Description

Usage: figurehandle= errorfill(x, y, E1, E2, ..., LineSpec)

Use this function to draw a curve and its areas of confidence. Draws the line y(x), then draws the areas E1(x), E2(x), ... (Well actually it's done in the opposite order, to minimize overlap.)

x:
The x values for y, E1, E2, ...
If x is a scalar, then (x, x+1, x+2, ...) is used.
If x is empty, then (1, 2, ...) is used.
Values must be finite and not NaN.

y:
Defines the curve, y(x).
Values must be finite and not NaN.

E:
The 'error' of y. Defines the area.
If E is a scalar, the shade will be between y(n)*(1+E) and y(n)*(1-E).
If E is of size (1,2) or (2,1), it will be between y(n)*(1+E(1)) and y(n)*(1-E(2)).
If E is a vector, the shade will be between y(n)+E(n) and y(n)-E(n).
If E is a double vector, the shade will be between y(n)+E(1,n) and y(n)-E(2,n).
Inf is marked by a jump up to a '^' symbol.
-Inf is marked by a jump down to a 'v' symbol.
NaN is marked by a jump up or down to a '*' symbol.

LineSpec:
(Default: 'k') Line specification for y(x), e.g. 'b+'.

NOTE:
The E:s must be given in increasing size, or an area will be covered by a previous and larger area.

COMPATIBILITY:
errorbar(x, y, E, LineSpec) corresponds to errorfill(x, y, E, LineSpec).
errorbar(x, y, L, U, LineSpec) corresponds to errorfill(x, y, [U; L], LineSpec).

EXAMPLE:
x= (1:0.25:10);
y= x.^2;
E3= [ones(1, length(x))*30; 0.7*y]; % 30 above and 0.3*y below
E3(1,7)= Inf;
E3(2,10)= Inf;
E3(2,25)= NaN;
errorfill(x, y, [0.1 0.02], 0.3, E3, 'b-+');
legend('E3', 'E2', 'E1', 'x^2','Inf','-Inf','NaN');

TO DO:
Make it work for y-values of Inf, -Inf, and NaN.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
confplot, JackKnife
This submission has inspired the following:
boundedline: line plots with shaded error/confidence intervals

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
26 Sep 2006 Erdem Arslan

I did not have time for detailed analysis of the code, but it worked without any problem and it seems pretty flexible.

Thank you,
It saved a lot of time.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
specialized Peder Axensten 22 Oct 2008 08:23:00
plotting Peder Axensten 22 Oct 2008 08:23:00
plot Peder Axensten 22 Oct 2008 08:23:00
errorplot Peder Axensten 22 Oct 2008 08:23:00
confidence interval Peder Axensten 22 Oct 2008 08:23:00
shad Peder Axensten 22 Oct 2008 08:23:00
patch Peder Axensten 22 Oct 2008 08:23:00
shaded plot Peder Axensten 22 Oct 2008 08:23:00
errors Peder Axensten 22 Oct 2008 08:23:00
errorplot Jentel Lu 29 Jan 2010 21:01:13

Contact us at files@mathworks.com