How to make graph multiple colors?

1 次查看(过去 30 天)
Wesley
Wesley 2013-1-17
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
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
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
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.
Wesley
Wesley 2013-1-17
For this data, I was given a table full of data points. I graphed the data by using plot(x,y). I then made the color black by doing plot(x,y,'--*k'). I want all the points to be black except for the point at 0, which I want to be red. I did not use scatter(). I'm not sure if plot(x,y) gives you points or lines.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by