Code covered by the BSD License  

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

image thumbnail

boundedline: line plots with shaded error/confidence intervals

by

 

05 May 2010 (Updated )

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

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

outlinebounds(hl, hp)
function hnew = outlinebounds(hl, hp)
%OUTLINEBOUNDS Outline the patch of a boundedline
%
% hnew = outlinebounds(hl, hp)
%
% This function adds an outline to the patch objects created by
% boundedline, matching the color of the central line associated with each
% patch.
%
% Input variables:
%
%   hl:     handles to line objects from boundedline
%
%   hp:     handles to patch objects from boundedline
%
% Output variables:
%
%   hnew:   handle to new line objects

% Copyright 2012 Kelly Kearney


hnew = zeros(size(hl));
for il = 1:numel(hp)
    col = get(hl(il), 'color');
    xy = get(hp(il), {'xdata','ydata'});
    ax = ancestor(hl(il), 'axes');
    
    hnew(il) = line(xy{1}, xy{2}, 'parent', ax, 'linestyle', '-', 'color', col);
end
    

Contact us