scatter3, colors indicate 3dimensions

조회 수: 3 (최근 30일)
Marilena Geng
Marilena Geng 2016년 7월 25일
댓글: Marilena Geng 2016년 8월 9일
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
  댓글 수: 1
Marilena Geng
Marilena Geng 2016년 8월 9일
awesome. So much easier than I thought! :D Thank you!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by