MATLAB Answers

Making a 2d scatter plot with multiple data sets and color map

17 views (last 30 days)
Joseph Tirado
Joseph Tirado on 2 Aug 2021
Commented: Star Strider on 2 Aug 2021
I am trying to plot three different data sets with data x, y and z against each other where z would depict the color. Right now I can only make a scatter plot that graphs x and y of the three data sets on the sane plot by doing this:
hold on;
hold on;
I want the z collumn or temp data to depict the color of the scatter data by creating a colormap however nothing I've been trying using the colormap function has been working. Any advice?

Answers (1)

Star Strider
Star Strider on 2 Aug 2021
Use the third argument of scatter to determine the size of the points, and the fourth argument of scatter to determine the colours:
x = randn(1,10);
y = randn(1,10);
z = randn(1,10);
scatter(x, y, [], z, 'filled','s')
See the documentation section on Vary Circle Color for details.
Star Strider
Star Strider on 2 Aug 2021
That definitely would have been appropriate, since the scatter function was posted!
If you have R2017a or later, the heatmap function may do what you want.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!