colour map scatter with multiple groups / variables

조회 수: 3 (최근 30일)
Gravey
Gravey 2018년 10월 19일
댓글: jonas 2018년 10월 22일
I have code to produce a coloured scatter. Figure 1 and two are separate variables that I would like to plot on the same axis. However when I try to do this (figure 3), the colour gradients change so that they are not considered per variable, but all together. Happy to consider other options that create a similar visual effect.
I have 14 variables in total that I want to plot in horizontal lines, with the colour of each marker representing the magnitude of the value. X axis must bet 0-100, represents normalised time. I'll paste below what I have used to create the images.
xData = 1:101 v = zeros(1,101); v(:) = 1; yData = v % random number between 1 and 2 cVect = MandARW(1:101,1); colormap jet hScat = scatter(xData, yData, 100, cVect, 'Filled', 's') hcbar = colorbar xlim([1 100]) %caxis([1 2])
figure(2)
xData = 1:101
v = zeros(1,101);
v(:) = 2;
yData = v % random number between 1 and 2
cVect = MandARW(1:101,2);
colormap jet
hScat = scatter(xData, yData, 100, cVect, 'Filled', 's')
hcbar = colorbar
xlim([1 100])
%ylim ([0 2])
figure(3)
xData = 1:101
v = zeros(1,101);
v(:) = 1;
yData = v % random number between 1 and 2
cVect = MandARW(1:101,1);
colormap jet
hScat = scatter(xData, yData, 100, cVect, 'Filled', 's')
hcbar = colorbar
xlim([1 100])
%caxis([1 2])
hold on
xData = 1:101
v = zeros(1,101);
v(:) = 2;
yData = v % random number between 1 and 2
cVect = MandARW(1:101,2);
colormap jet
hScat = scatter(xData, yData, 100, cVect, 'Filled', 's')
hcbar = colorbar
xlim([1 100])
%ylim ([0 2])
  댓글 수: 2
jonas
jonas 2018년 10월 19일
편집: jonas 2018년 10월 19일
Are you saying that you want to scale the color of each data set, so that each bar range from blue to red? This would be easy, but the values on the colorbar would be useless.
Gravey
Gravey 2018년 10월 19일
Yes, I do want to scale the data set / vector / variable. I just want to visualise where the peaks and troughs are (reds and blues) for multiple vectors at once. I do not need the colorbar to provide values, just that reds are high and blues are low. I hope this makes sense.

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

채택된 답변

jonas
jonas 2018년 10월 20일
편집: jonas 2018년 10월 20일

I would probably just create a new axes for each new scatter object. Each object then scales automatically and the same method works for other objects such as surfaces. Example:

x = linspace(0,2*pi,100);
y = zeros(size(x))
z1 = sin(x);
z2 = sin(x).*2;
z3 = sin(x).*-2;
ax(1) = axes('color','none');hold on
scatter(x,y,[],z1,'filled')
ax(2) = axes('color','none','xcolor','none','ycolor','none');hold on
scatter(x,y+1,[],z2,'filled')
ax(3) = axes('color','none','xcolor','none','ycolor','none');hold on
scatter(x,y+2,[],z3,'filled')
linkaxes(ax,'xy')
  댓글 수: 2
Gravey
Gravey 2018년 10월 22일
Thank you :)
jonas
jonas 2018년 10월 22일
My pleasure!

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

추가 답변 (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