필터 지우기
필터 지우기

What is the best way to fill the areas between lines in a graph?

조회 수: 56 (최근 30일)
HC
HC 2015년 4월 23일
댓글: Stefan 2023년 5월 18일
I have to plot a the wave patterns in a nozzle and I want to highlight the changes with filling the areas between the lines with color but I can't find a way to do this.

채택된 답변

Image Analyst
Image Analyst 2015년 4월 23일
How about using patch() or fill()? Or you can use area() if you plot the top curve first and they don't overlap any.

추가 답변 (2개)

Image Analyst
Image Analyst 2015년 4월 24일
HC, I haven't heard from you so I guess you must be having trouble. Here is a demo:
curve1 = 10 + randi(2, 1, 20);
curve2 = 1 + randi(2, 1, 20);
% Find area coordinates.
inBetweenRegionX = [1:length(curve1), length(curve2):-1:1]
inBetweenRegionY = [curve1, fliplr(curve2)];
% Display the area first so it will be in the background.
fill(inBetweenRegionX, inBetweenRegionY, 'g');
hold on;
% Now plot the curves and markers on top of the area.
plot(curve1, 'rd-', 'LineWidth', 3);
plot(curve2, 'bs-', 'LineWidth', 3);
grid on;
ylim([0,13]);
If this meets your needs, please mark it as Accepted. Thanks in advance.
  댓글 수: 5
Image Analyst
Image Analyst 2023년 5월 18일
@Stefan Rather than hijack @HC's question (even though your question is related), could you please start your own new question?
Stefan
Stefan 2023년 5월 18일
sorry have done so.

댓글을 달려면 로그인하십시오.


Amy Farris
Amy Farris 2018년 3월 13일
Thank you so much for this answer! It was very helpful to me!!!
  댓글 수: 1
Image Analyst
Image Analyst 2018년 3월 14일
You're welcome. If it solved your problem, please mark it as Accepted. Thanks in advance.

댓글을 달려면 로그인하십시오.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by