필터 지우기
필터 지우기

Linking marker face color to colorbar

조회 수: 27 (최근 30일)
Christo van Rensburg
Christo van Rensburg 2019년 10월 13일
댓글: Christo van Rensburg 2019년 10월 13일
Hi
How do I link the face color of a marker to a colorbar? I have the following code so far:
plot(ones(length(cds_BD),1)*srs(1), v0_BD,'ks'), hold on
plot(ones(length(cds_GD),1)*srs(2), v0_GD,'ks')
plot(ones(length(cds_PRD),1)*srs(3), v0_PRD,'ks')
caxis([40 70]);
colorbar
Where "cds_**" and "srs" are defined arrays. Each entry in the matrix cds_** is linked to a initial velocity and I would like to color the marker's face with that color according to the colorbar.
Please help.
Thanks
  댓글 수: 2
darova
darova 2019년 10월 13일
Can you attach some data? Image?
Christo van Rensburg
Christo van Rensburg 2019년 10월 13일
Hi
Find below the data:
cds_BD = [1.1105 1.3124 1.0474 1.0978 1.0852 1.0474 1.0221 1.0347 1.1988];
cds_GD = [0.8256 0.9615 0.9406 0.7524 1.0660 0.7838 0.8256 0.9301 0.7733];
cds_PRD = [0.9761 0.9964 0.9862 1.0472 0.9659 1.0066 0.9252 0.9151 0.9354];
v0_BD = [58.5101 58.2125 58.4750 62.5083 62.4396 62.3959 67.1816 66.3405 66.7731];
v0_GD = [61.1054 61.5469 61.4117 63.8668 64.1549 64.4764 66.8466 67.5859 67.2018];
v0_PRD = [61.6887 62.5646 62.5521 66.3803 65.8711 65.7790 69.4217 68.7722 68.5662];
So what I essentially want is to give each marker's face a color according to a colormap for a range of velocities.

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

채택된 답변

darova
darova 2019년 10월 13일
Try scatter
clc,clear
cds_BD = [1.1105 1.3124 1.0474 1.0978 1.0852 1.0474 1.0221 1.0347 1.1988];
cds_GD = [0.8256 0.9615 0.9406 0.7524 1.0660 0.7838 0.8256 0.9301 0.7733];
cds_PRD = [0.9761 0.9964 0.9862 1.0472 0.9659 1.0066 0.9252 0.9151 0.9354];
v0_BD = [58.5101 58.2125 58.4750 62.5083 62.4396 62.3959 67.1816 66.3405 66.7731];
v0_GD = [61.1054 61.5469 61.4117 63.8668 64.1549 64.4764 66.8466 67.5859 67.2018];
v0_PRD = [61.6887 62.5646 62.5521 66.3803 65.8711 65.7790 69.4217 68.7722 68.5662];
x0 = cds_BD*0;
h(1) = scatter(x0+1, v0_BD, [], cds_BD);
hold on
h(2) = scatter(x0+2, v0_BD, [], cds_GD);
h(3) = scatter(x0+3, v0_BD, [], cds_PRD);
hold off
set(h,'Marker','s')
set(h,'SizeData',50)
% caxis([40 70]);
colorbar
axis([0 4 55 70])
  댓글 수: 2
darova
darova 2019년 10월 13일
Use this option to fill markers
set(h,'MarkerFaceColor','flat') % fill markers
Christo van Rensburg
Christo van Rensburg 2019년 10월 13일
Hi
It works perfectly, thanks so much darova!!

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

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