How to make graph multiple colors?
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a graph in matlab that is a line. The data ranges from 0 to 1000. I want to make the data at 0 to be one color and for all the other data to be another color. How do I do this?
Thanks
댓글 수: 1
Jing
2013년 1월 17일
I'm not sure whether there's way to achieve this in a single line. But you can get the same appearance with multiple lines.
답변 (1개)
Image Analyst
2013년 1월 17일
Data are just points. Lines go in between the points. What is "data"? Is it your "y" values, or your x values? Let's say
x = [0,2,4,5,6,8];
y = [1,0,3,3,0,9];
Do you want the marker at (x,y) = (0,10) to be color1 and all the other markers to be color2, or do you want the lines coming out both sides of the y=0 points going to the adjacent points be different colors? In other words, the line from (0,1) to (2,0) and the line going from (2,0) to (4,3) etc. I'm not sure if it's the markers at the data locations you want or if it's the lines in between the data locations. I'm not sure what "make the data at 0 to be one color" means, especially after you were talking about lines, not points. Please clarify. Either way you can use two plot() calls.
댓글 수: 4
Walter Roberson
2013년 1월 17일
Do you want lines connecting the points, or no lines? If you do not want lines connecting the points, then use scatter() as that allows you to adjust the colors on a point-by-point basis. If you do want lines connecting the points, then you need to tell us what color to use for the line connecting points of different color.
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!