필터 지우기
필터 지우기

Coloring the lines in a a graph

조회 수: 1 (최근 30일)
Bob Choy
Bob Choy 2012년 11월 18일
I have a graph with 18 horizontal lines, I need to first 6 lines to be colored magenta, the following 6 to be cyan and the last 6 to be red. Then I want to add a small label to that graph saying something like [0-6 = A], [6-12 = B] and [12-18 = C].
Is this possible?
Thank you.

답변 (1개)

Image Analyst
Image Analyst 2012년 11월 18일
Yes. Use the 'Color' option in line()
x1 = 0;
x2 = 20;
for y = 1 : 6
line([x1 x2], [y y], 'Color', 'm');
hold on;
end
for y = 7 : 12
line([x1 x2], [y y], 'Color', 'c');
end
for y = 13 : 18
line([x1 x2], [y y], 'Color', 'r');
end
  댓글 수: 2
Bob Choy
Bob Choy 2012년 11월 18일
편집: Bob Choy 2012년 11월 18일
Can you please elaborate? More especifically, what should I be doing? What is x1 and x2?
Walter Roberson
Walter Roberson 2012년 11월 18일
The above is fairly specific. line() is a MATLAB plotting call. Calling it with the parameter/value pairs shown will give you magenta or cyan or read lines.

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

카테고리

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