How can I plot distribution with shades?
조회 수: 2 (최근 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?
댓글 수: 0
답변 (1개)
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
2015년 9월 18일
% 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 Center 및 File Exchange에서 Bar Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!