Question on a scatter plot

1 次查看(过去 30 天)
I did a bunch of searching but to no avail.
I am trying to make a plot with x and a corresponding y value (this is the easy part)
I want to include a 3rd value (which in my case is a corresponding RSM) And I want to make the lower values be one color, and gradually go to a different color for different values. So for every point on the plot, it has a color, darker being a low (or high) RMS value, and lighter being a high (or low) RMS.
I have tried gscatter, but I can't make it look like I need.
gscatter(x,y,RMS)
Thanks

采纳的回答

Walter Roberson
Walter Roberson 2013-10-21
pointsize = 10;
scatter(x(:), y(:), pointsize, RMS(:));
No need to scale the color to 0-255 range.
  1 个评论
Image Analyst
Image Analyst 2013-10-21
You're right - I didn't know about that option.
If C is a three column matrix with the number of rows in C equal to the length of X and Y,then each row of C specifies an RGB color value for the corresponding circle.
If C is a vector with length equal to the length of X and Y, then the values in C are linearly mapped to the colors in the current colormap.
I was talking about the first one and you brought up the second option, which I didn't know about but looks simpler.
x = 1:100; % Example
y = 1:100;
RMS = 1:100;
pointsize = 50;
scatter(x(:), y(:), pointsize, RMS(:));

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2013-10-21
Scatter() takes arrays where you can define the size and color of the markers. Did you try to set them to something?
  2 个评论
Michael
Michael 2013-10-21
There is 100 points in plot that I am trying to generate. The X and Y parts are largely linear, the RMS values are not.
Wouldn't going on each point specifying a color be overly tedious?
Image Analyst
Image Analyst 2013-10-21
编辑:Image Analyst 2013-10-21
Not if you do it correctly. Convert each value into a number from 0-255 where your min value is 0 and your max value is 255, for example using mat2gray() if you have the Image Processing Toolbox or manually if you don't. Then set each color in the colormap that you pass in to scatter() equal to the color from that row of a standard colormap like jet(255) so your min values will look blue and your max values will look red and in between values will be in between colors of the rainbow. You can use a simple for loop for that. I'll code it up later tonight when I have more time.

请先登录,再进行评论。

类别

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