![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278042/image.png)
How to shade area between three lines?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Youngmin
am 19 Mär. 2020
Kommentiert: Star Strider
am 19 Mär. 2020
Hello,
I would like to shade under the curve at which is greater than 1 in y value and greater than 20 in y value in the figure below. ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278040/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278040/image.jpeg)
But, fill function seems to allow shading the area between two vectors and not allow to use xline and/or yline functions at the same time. Please let me know how I can fill the area (upper right side area under the curve).
0 Kommentare
Akzeptierte Antwort
Star Strider
am 19 Mär. 2020
Bearbeitet: Star Strider
am 19 Mär. 2020
I believe there is an error in your description.
Try this interpretation of what I believe you intend:
x = linspace(0, 50); % Create Data
y = 6 * (exp(-(x-10).^2/25) + exp(-(x-25).^2/50)); % Create Data
Lvy = (y > 1) & (x > 20);
figure
plot(x, y)
hold on
patch([x(Lvy) fliplr(x(Lvy))], [ones(size(x(Lvy))) fliplr(y(Lvy))], 'g')
hold off
EDIT —
Added plot figure:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278042/image.png)
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!