How to complete fill between 2 lines.

1 view (last 30 days)
I'm trying to use the command fill(x) to fill the area between two lines however an awkward line is happening in the middle.
Gov = [0 14.937 16.978 18.047 18.746 19.536 19.900 20.045 20.128 20.946 20.900 20.923];
Prof = [-52 -352 -752 -1012 -1212 -1532 -1682 -1800 -1930 -2350 -2420 -2550];
Gpp = [0 8.500 9.795 1.417 3.795 9.620 8.499 14.523 16.890 15.569 20.227 19.750];
Gfr = [0 12.756 13.387 6.959 8.779 12.924 12.300 16.363 17.970 17.361 20.451 20.141];
figure(1)
plot(Gov,Prof,Gpp,Prof,Gfr,Prof)
%fit Gov
v = smooth(Gov);
figure(2)
plot (v, Prof,'b')
hold on
plot (Gov, Prof, 'b:')
%fit Gpp
p = smooth(Gpp);
figure(2)
plot(p,Prof,'r'),
plot(Gpp, Prof, 'r:')
%fit Gfr
f = smooth(Gfr);
figure(2)
plot(f,Prof, 'y')
plot(Gfr,Prof, 'y:')
hold off
%Coloring Area
figure (3)
plot(p, Prof,'r', f, Prof,'y', v, Prof,'b')
hold on
X = [p fliplr(f)];
Y = [Prof];
fill(X,Y,'m')
hold off
This is what I got:
My objective is:

Accepted Answer

Jan
Jan on 7 May 2018
X = [p(:).', fliplr(f(:).')];
Y = [Prof, fliplr(Prof)];
fill(X, Y, 'm')

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!