フィルターのクリア

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 Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by