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!