scatter3, colors indicate 3dimensions

2 次查看(过去 30 天)
Dear all, I have 3 vectors, flux1, flux2 and temperature, both fluxes depending on temperature. I plotted all 3 in a figure using scatter3. Now I'd like to color the Markerpoints depending on their hight (=according temperature) so that the scatterpoint cloud is easier to read. I know with: scatter3(x,y,z,s,c), c gives an option to do this but I don't seem to understand how to create a c matrix. I randomly tried this:
figure
test = [flux1.';flux2.';temp.'].';
scatter3(flux1,flux2,temp,20,test,'*')
view([10 20])
zlabel('Temperature')
xlabel('sensible heat flux')
ylabel('latent heat flux')
set(gca,'Color',[0.8 0.8 0.8]);
but I'm not happy about it (too much white colored points for high values) and I'd love to actually understand where the coloring comes from my random c-matrix and how I can influence that. Any suggestions and hints? :)
Sorry if this is a very basic question but I couldn't find an answer in the Documentation and I'm pretty new to matlab.

采纳的回答

Vandana Rajan
Vandana Rajan 2016-8-8
Hi,
To color the marker points according to the temperature intensity, put c = temp. Now the values in 'c' are linearly mapped to the current colormap. The command 'colorbar' shows the current colormap on the side of figure.
clearvars; close all; clc;
%%create the 3 vectors
a = -50;
b = 50;
flux1 = (b-a).*rand(100,1) + a;
flux2 = (b-a).*rand(100,1) + a;
temp = linspace(-5,15,100);
%%when c is of same length as flux1, flux2 and temp, then values in c are linearly mapped to the current colormap
% The command 'colorbar' shows the current colormap on the side of the
% figure
figure;
scatter3(flux1,flux2,temp,20,temp,'*');
zlabel('Temperature')
xlabel('sensible heat flux')
ylabel('latent heat flux')
title('With c = temperature');
colorbar
A number of built-in colormaps are available in MATLAB. You can choose a colormap of your taste. You can also use your own customized colormaps. See this link for more details. http://www.mathworks.com/help/matlab/ref/colormap.html

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by