How can I plot distribution with shades?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Joseph Cheng
le 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 commentaire
Kelly Kearney
le 18 Sep 2015
% 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);
Voir également
Catégories
En savoir plus sur Bar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!