필터 지우기
필터 지우기

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에서 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