How can I plot distribution with shades?

4 次查看(过去 30 天)
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?

回答(1 个)

Joseph Cheng
Joseph Cheng 2015-9-18
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 个评论
Kelly Kearney
Kelly Kearney 2015-9-18
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);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Bar Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by