Changing colors in scatter plots?

4 次查看(过去 30 天)
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 个评论
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
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 个评论
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 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by