Area fill between minimum and maximum axis limit

1 view (last 30 days)
Hi,
What is the easiest way to fill up the area of the following data:
data=[
15057 11.276 13.607
15058 11.275 13.612
15058 11.272 13.618
15059 11.27 13.624
15059 11.268 13.63
15060 11.266 13.636
15060 11.263 13.642
15061 11.261 13.648
15061 11.259 13.654
15062 11.256 13.659
15062 11.254 13.665
15063 11.252 13.671
15063 11.25 13.677
15064 11.247 13.683
15064 11.245 13.689
15065 11.243 13.695
15065 11.24 13.701
15066 11.238 13.707
15066 11.236 13.712
];
idx = data(:,1)
data_1 = data(:,2);
data_2 = data(:,3);
What I intend to do is to fill the area from the left-limit to data_1 (with red) and from data_2 right-limit (with blue)]. Thus, the area in between the two curve will be white.

Accepted Answer

Star Strider
Star Strider on 4 Oct 2019
You need to create a closed area for patch, that proceeds clockwise (or anticlockwise).
The Code —
figure
patch([data_1; flipud(data_2)], [idx; flipud(idx)], 'r')
ylabel('Index')
The Plot —

More Answers (1)

darova
darova on 3 Oct 2019
Use patch()
  1 Comment
BeeTiaw
BeeTiaw on 3 Oct 2019
Edited: BeeTiaw on 3 Oct 2019
I know, but I could not get what I want
patch([data_1' fliplr(data_1')], [index max(index)*ones(size(index))], 'r');

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!