How can I plot distribution with shades?

2 Ansichten (letzte 30 Tage)
Giorgi
Giorgi am 18 Sep. 2015
Kommentiert: Kelly Kearney am 18 Sep. 2015
Hello Matlabers :)
I have timeseries that I forecast for 12 period for 1000 times so I have 12X1000 matrix now and I want to make chart like this
Can anyone help me?

Antworten (1)

Joseph Cheng
Joseph Cheng am 18 Sep. 2015
you'd do something like this where you would use fill to generate the ranges of the distribution
t = 0:.1:10;
x = 2*t.^2;
ulimit= 10*rand(size(x));
llimit= 10*rand(size(x));
hold on
h(1)=fill([t fliplr(t)],[x+3*ulimit fliplr(x-3*llimit)],'g','edgecolor','none')
h(2)=fill([t fliplr(t)],[x+2*ulimit fliplr(x-2*llimit)],'b','edgecolor','none')
h(3)=fill([t fliplr(t)],[x+ulimit fliplr(x-llimit)],'r','edgecolor','none')
set(h,'facealpha',.5)
plot(t,x,'b');
  1 Kommentar
Kelly Kearney
Kelly Kearney am 18 Sep. 2015
My boundedline.m can help automate the procedure Joseph outlined:
% Data
t = (1:1000)';
y = 2*t.^2;
err = bsxfun(@times, rand(1000,12), t*1000);
y = bsxfun(@plus, y, err);
% Calculate bounds and plot
ymed = median(y, 2);
prc = [0 10 25 75 90 100];
p = prctile(y, prc, 2);
ylo = bsxfun(@minus, ymed, p(:,1:length(prc)/2));
yhi = bsxfun(@minus, p(:,end:-1:length(prc)/2+1), ymed);
bnd = permute(cat(3,ylo,yhi), [1 3 2]);
[hl, hp] = boundedline(t, [ymed ymed ymed], bnd);

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by