2
votes

I have data where the X(time), Y1 (Median values), Y2(25th percentile) and Y3(75th percentile). Now i want to plot all these in the same plot, and shade the area between the median curve and upper quartile curve and again shade the area between median curve and lower quartile curve. Is there some easy way to do this?

I tried the option xx = [X,X]; yy = [Y1,Y2]; fill(xx,yy,'b');

.. But I am not happy with the above code as it does not give me the plot that I am looking for. Please could someone help me.!! Many thanks SSR

1
The FEX is always a good place to start searching for stuff like this.knedlsepp

1 Answers

2
votes

Is this what you want?

x = 0:.01:1;
y1 = 5+sin(2*pi*x);
y2 = y1-1;
y3 = y1+1; %// example values
fill([x x(end:-1:1)],[y3 y1(end:-1:1)],[.6 .6 .6]) %// light grey
hold on
fill([x x(end:-1:1)],[y2 y1(end:-1:1)],[.4 .4 .4]) %// dark grey

enter image description here