change marker color based on the values

조회 수: 112 (최근 30일)
Turbulence Analysis
Turbulence Analysis 2022년 5월 18일
댓글: Mathieu NOE 2022년 5월 18일
Hi,
I have a matrix B of 94859 x 3. In the the below command, I would like to change each individual marker color based on the data values stored in the B(:,3). Could somebody help me with this ??
plot (B(:,1),B(:,2), '*');

채택된 답변

Mathieu NOE
Mathieu NOE 2022년 5월 18일
hello
my suggestions below
S = 35; % size of symbols in pixels
% normalize vector to go from zero to 1
normV = (B(:,3)-min(B(:,3)))./(max(B(:,3))-min(B(:,3)))
% blue to red.
C = [normV zeros(size(normV)) 1-normV];
figure
scatter(B(:,1),B(:,2),S,C,'Marker','s')
colorbar('vert');
% jet colors
CC = jet(numel(normV));
figure
scatter(B(:,1),B(:,2),S,CC,'Marker','s')
colorbar('vert');
  댓글 수: 3
Turbulence Analysis
Turbulence Analysis 2022년 5월 18일
Thanks!!
Mathieu NOE
Mathieu NOE 2022년 5월 18일
My pleasure !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by