How to plot the area between the 2 curves with transparency 50% ?

조회 수: 7 (최근 30일)
Mustafa Sobhy
Mustafa Sobhy 2022년 2월 13일
답변: Star Strider 2022년 2월 13일
y = [0;2;4;8;12;15;19;21;23;26;29;32;36;40;43;45];
h=[-0.4270; -0.3210;-0.3600;-0.2967;-0.1400;-0.0876;-0.2430;-0.4170;-0.9860;-0.7460;-0.6430;-0.5470;-0.4300;-0.3210;-0.2500;-0.2890];
l=[-0.2200;-0.1060;-0.1150;-0.0640;0.0550;0.0870;-0.0309;-0.2110;-0.7630;-0.5440;-0.4410;-0.3650;-0.2290;-0.1160;-0.0590;-0.0946];
plot(y,h,'b');hold on;
plot(y,l,'b');

채택된 답변

Star Strider
Star Strider 2022년 2월 13일
y = [0;2;4;8;12;15;19;21;23;26;29;32;36;40;43;45];
h=[-0.4270; -0.3210;-0.3600;-0.2967;-0.1400;-0.0876;-0.2430;-0.4170;-0.9860;-0.7460;-0.6430;-0.5470;-0.4300;-0.3210;-0.2500;-0.2890];
l=[-0.2200;-0.1060;-0.1150;-0.0640;0.0550;0.0870;-0.0309;-0.2110;-0.7630;-0.5440;-0.4410;-0.3650;-0.2290;-0.1160;-0.0590;-0.0946];
figure
plot(y,h,'b')
hold on
plot(y,l,'b')
patch([y; flipud(y)], [h; flipud(l)], 'r', 'FaceAlpha',0.5, 'EdgeColor','none')
hold off
The approach is to create a closed, continuous curve for patch to fill. That is the reason for the flip (here flipud) calls.
See the docujmentation on patch for more information on it.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by