필터 지우기
필터 지우기

Shading Between Two Lines

조회 수: 89 (최근 30일)
AnnieLieseMari
AnnieLieseMari 2022년 7월 25일
편집: Star Strider 2022년 7월 25일
I have a plot with two lines on it, as seen below. To get these lines, I've plotted the following.
plot(HH, LWAC, '-')
hold on
plot(HH, LWAR, '-')
HH is a wind speed value from 4-20. LWAC and LWAR are both separate vectors of y-values.
What I need to do is have MATLAB shade between the two lines. How can I go about doing that?

답변 (1개)

Star Strider
Star Strider 2022년 7월 25일
편집: Star Strider 2022년 7월 25일
It would be easier with your data.
Assuming that all the vectors are coiumn vectors —
HH = linspace(4, 20).';
LWAC = 10*(1 - exp(-0.1*HH)) + 92;
LWAR = 10*(1 - exp(-0.1*HH)) + 94;
figure
patch([HH; flip(HH)], [LWAC; flip(LWAR)], [1 1 1]*0.8, 'EdgeColor','none')
hold on
plot(HH, LWAC, '-')
plot(HH, LWAR, '-')
hold off
That should do what you want. Experiment to get different results.
EDIT — (25 Jul 2022 at 21:18)
See the documentation on patch for details.
.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by