필터 지우기
필터 지우기

Fill three areas in a plot with one line

조회 수: 2 (최근 30일)
leonidas86
leonidas86 2018년 7월 11일
답변: Star Strider 2018년 7월 11일
Hello, I have one vector with my x axis values, one vector with the y axis values for my line and a min and max value for the y limits of my figure. Now I want to fill the area under the x-axis with one color, the area between the x axis and the line with one color and the area between the line until to my max value with another color. How can I do this?
Thanks for your help!

답변 (1개)

Star Strider
Star Strider 2018년 7월 11일
I am not certain what you want.
Try this:
x = sort(rand(1, 20));
y = rand(1, 20) + 0.5;
ylow = 0.3; % Low Y-Limit
yhigh = 1.8; % High Y-Limit
x1 = ones(size(x));
figure(1)
patch([x fliplr(x)], [x1*ylow fliplr(y)], 'g')
hold on
patch([x fliplr(x)], [x1*yhigh fliplr(y)], 'r')
patch([x fliplr(x)], [x1*min(ylim) x1*ylow], 'b')
hold off
ylim = [ylow yhigh];

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by