Changing colors in scatter plots?

Greetings all,
I was trying to somehow change colors of a scatter plot I have of two values.
What I started off with was this:
scatter(ModelFile(:,4), z_i_1_abs)
where the "x" value - ModelFile(:,4) has 1156x1 values, and the same for the "y" value - z_i_1_abs - it also has 1156x1 values. This line plots succesfully, but I want ModelFile(:,4) to be one color and z_i_1_abs to be a separate color. When I plot it now, both are blue.
So I looked at gscatter and the good old plot command, and I tried hold on, but I just keep getting errors.
Any advice?
Thanks!
-J

댓글 수: 5

Image Analyst
Image Analyst 2012년 2월 25일
I don't understand. It's a scatter plot - it's not like you have two different sets of data where you can plot each with a certain color against some independent x axis. Your array ModelFile DEFINES the x axis. You have the kth point at (x,y) where x=ModelFile(k,4) and y = z_i_1_abs(k). What's to distinguish one set from the other?
Jesse
Jesse 2012년 2월 28일
Walter,
Sorry getting back to this so late, but I never received an email stating that my post was updated.
Ok, I see what your saying now, and I just thought that your array values in the first position (or x) could have different colors since the "y" values is another column of data. That's all I was checking.
I was looking at something on the web and I thought that this could be accomplished - apparently not.
Jiro Doke
Jiro Doke 2012년 2월 28일
Right. You can't have 2 colors for a single point. You can't even do that with a paper and a colored pencil. Unless you're saying you want half of the circle to be one color and the other half of the circle to be another. But I doubt that's what you want.
Walter Roberson
Walter Roberson 2012년 2월 28일
By the way: Image Analyst's name is not "Walter".
Jesse
Jesse 2012년 2월 28일
Ok, apologies for the confusion about the names. Honestly I saw your name Walter, but Image Analyst's was the only comment that appeared - not yours, so I mistakenly thought you were two of the same people.
To all the others, thanks for the feedback, but hey I'm no expert at MATLAB. I just thought I could have one column in one color and the other column in another color, that's all. No need to persecute someone for learning.

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

 채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 28일

0 개 추천

I'm not sure what you think you want, but perhaps:
dotsize = 10;
n = length(z_i_1_abs);
scatter( 1:n, ModelFile(:,4), dotsize, 'b');
hold on
scatter( 1:n, z_i_1_abs, dotsize, 'r');

댓글 수: 3

Jesse
Jesse 2012년 2월 28일
Yes that's what I was looking for - thank you.
Walter Roberson
Walter Roberson 2012년 2월 28일
We wouldn't normally think of that as a scatter plot.
Another way of accomplishing the same thing would be:
plot( [ModelFile(:,4), z_i_1_abs(:)], 'o')
This can be extended to any number of columns, but each column must be the same size. (Also, colors would start to repeat after the 8th column.)
Jesse
Jesse 2012년 2월 29일
Cool - thanks for all of the insight! I appreciate it.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by