shade area between graphs
조회 수: 2,971(최근 30일)
I want to shade the area between these graphs
but this certainly does not do the trick:
fill([t t(end:-1:1)],[y1 y2(end:-1:1)],'y')
I also downloaded and tried "jblill"
but that did not seem to amend the outcome so far
Image Analyst 2015년 2월 28일
Try using fill() instead of area():
x = 1 : 300;
curve1 = log(x);
curve2 = 2*log(x);
plot(x, curve1, 'r', 'LineWidth', 2);
plot(x, curve2, 'b', 'LineWidth', 2);
x2 = [x, fliplr(x)];
inBetween = [curve1, fliplr(curve2)];
fill(x2, inBetween, 'g');
Javier Montalt Tordera 2019년 4월 12일
This can be simplified using the function shade (in MATLAB File Exchange).
The syntax for the above problem would be:
shade(t,y1,t,y2,'FillType',[1 2;2 1]);
The FillType option specifies that the area between lines 1 and 2 should be filled, whether 1 is above 2 or the other way round.
DETELINA IVANOVA 2018년 4월 4일
I am using this last suggestion by Star Strider to plot error bar shading using patch, but in some cases I get in addition to the shading straight lines (see the third plot at the bottom in the attached figure) I have eliminated the points with NaNs. It seems ok in the other two cases (the upper plots in the same figure). What can be causing this?