File Exchange

image thumbnail

Shaded area error bar plot

Error bar plot with filled area curves.

147 Downloads

Updated 09 Oct 2018

View License

This function plots the mean and standard deviation of a set of data filling the space between the positive and negative mean error using a semi-transparent background, completely customizable.

Input parameters:
- data: Data matrix, with rows corresponding to observations and columns to samples.
- options: (Optional) Struct that contains the customized params.
* options.handle: Figure handle to plot the result.
* options.color_area: RGB color of the filled area.
* options.color_line: RGB color of the mean line.
* options.alpha: Alpha value for transparency.
* options.line_width: Mean line width.
* options.x_axis: X time vector.
* options.error: Type of error to plot.
if 'std', one standard deviation;
if 'sem', standard error mean;
if 'var', one variance;
if 'c95', 95% confidence interval.
Example of use:
data = repmat(sin(1:0.01:2*pi),100,1);
data = data + randn(size(data));
plot_areaerrorbar(data);

Cite As

Víctor Martínez-Cagigal (2019). Shaded area error bar plot (https://www.mathworks.com/matlabcentral/fileexchange/58262-shaded-area-error-bar-plot), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Anoop B J

Hi,

I am having a problem with setting the x axis right. Other things seem to work fine. But the x axis is only drawn between 1 and 2. Could you help out with that please?

Below is the data I am working with. I want to plot a scatterplot with shaded confidence intervals.

a = [146.146 154.006
144.498 148.602
117.563 145.987
108.53 113.418
109.366 119.78
128.15 132
115.02 120.584
122.88 125.69
140.109 150.013
99.347 100.333
112.768 113.58
104.246 114.114
];

When I try
plot_areaerrorbar(a), the x axis is between 1 and 2. I am not able to understand how to make the plot to be the same length as my data.

Rob Campbell

Might be neater with an input parser instead of the structure for the optional arguments: https://ch.mathworks.com/help/matlab/ref/inputparser.addparameter.html

Javier

Javier

Thank you. Excellent function.

Updates

1.3.1

Name

1.3

Due to changes in std() function, now calculates the proper standard deviation across observations.

1.2.0.0

Title is modified.

1.1.0.0

Now the function displays one standard deviation up and one down.

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux