Code covered by the BSD License  

Highlights from
boundedline: line plots with shaded error/confidence intervals

4.57143

4.6 | 8 ratings Rate this file 116 Downloads (last 30 days) File Size: 3.95 KB File ID: #27485
image thumbnail

boundedline: line plots with shaded error/confidence intervals

by Kelly Kearney

 

05 May 2010

Plot one or more lines with a shaded boundary (can represent error, confidence intervals, etc).

| Watch this File

File Information
Description

This function allows you to plot one or more lines with their error range/confidence intervals/whatever bounds you require. It provides an advantage over several other similar entries on the FEX in that it:

1) allows x-y input similar to plot, where one call can create multiple lines at once, either by listing consecutive x-y pairs or by using using matrices for x and/or y.

2) can add bounds in either the x- or y-direction, leading to support of plots where the x axis represents the dependent variable

3) can render the shaded bounds either with transparency or as a lighter opaque patch, allowing flexibility with different renderers (helpful when OpenGL acts up, as it often does on my own computer).

4) Can use linespec definitions, a colormap, or the default color order, as well as varying color intensity for the shaded bounds, for flexible color of lines and bounds

5) returns handles of lines and patches for future modification if necessary

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
confplot, errorfill, shadedErrorBar

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
19 May 2010 Zachary Danziger

Nice file. I enjoy the flexibility.

09 Jun 2010 Dylan

This is a very useful function that does almost exactly what I was trying to do, and it should save me a lot of time. Thanks for making it!

I think, though, that it would be even more useful if you made two modifications:

1) The reference color of the bounded area should be set independently (as an RGB array), rather than being constrained to be a lighter shade of the corresponding line color. This would be particularly relevant for users preparing b&w figures for publication who, for example, might want to use two black lines and two different shades of grey for the bounded areas. The specific example I provided could of course be facilitated simply by allowing separate transparency parameters for each bounded area, but that still would not provide as much flexibility as some users might want.

2) The default behavior of 'legend' is to use shaded boxes that are the same colors as the bounded areas. Some users might prefer that the legend use lines of the same color and style as the corresponding data. It would be nice to have the option of using either. I believe this could be controlled from within boundedline.m by setting the 'IconDisplayStyle ' property of the 'LegendEntry' array of each patch to 'on' or 'off'.

Example code:
set(get(get(hPatches(1),'Annotation'),'LegendInformation'),'IconDisplayStyle','off')

Also, there appears to be a bug (using R2007b): adding a legend to a figure that was made using the 'alpha' option results in no legend and no bounded areas.

10 Aug 2010 Alexander

I experienced the following problem on my mashine with nVidia graphics:
When using the 'alpha' option the axes are overlayed. This a problem caused by the OpenGL rendering.
Workaround: activate software rendering by
opengl software;

11 Aug 2010 Alexander  
06 Jan 2011 Il

Awesome. It works perfectly on the screen.
The only problem for me is that the transparent color cannot be exported with vector graphics pdf. If opengl renderer is used, it will convert it to raster, which is not so desirable.

26 Mar 2011 Felipe G. Nievinski

good job in pointing out advantages over several other similar entries on the FEX.

26 Aug 2011 Vassilis Kehayas  
07 Oct 2011 dbgtjp  
07 Oct 2011 dbgtjp

excellent work.
if anybody else wants to avoid the patches appear in the legend simply add the following code after line 314.

set(get(get(hp(iln),'Annotation'),'LegendInformation'),'IconDisplayStyle','off');

this does the trick.

30 Jan 2012 Mohammed Alwesabi  
20 May 2012 Gideon simpson

Works well, but is it possible to put one of the axes on a log scale?

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
bounds line confidence interval errorbar shaded Kelly Kearney 05 May 2010 12:21:12

Contact us at files@mathworks.com