Azzera filtri
Azzera filtri

系統樹と散布図の色を連動させる方法

5 visualizzazioni (ultimi 30 giorni)
早恵香
早恵香 il 17 Nov 2023
Commentato: Dyuman Joshi il 18 Nov 2023
系統樹と散布図の色を連動させるやり方はないのでしょうか。
参照となるコードは以下の通りです。
今回の質問内容を具体的に話せばf3の系統樹をf2の散布図と同じ配色にしたいのですが
load fisheriris
Z = linkage(meas,'average','chebychev'); % 階層クラスターツリーの作成
cutoff = median([Z(end-2,3) Z(end-1,3)]); % クラスターを3つに分けれるよう中間点でカット
f1 = figure;
ZCount = length(find(Z(:,3)>cutoff)) + 1;
[~,Zleaf] = dendrogram(Z,ZCount); % グループ分け
f2 = figure;
orgplot = gscatter(meas(:,1),meas(:,2),Zleaf); % 読み込んだデータをグラフ化して確認
%% 系統樹の出力
f3 = figure;
d = dendrogram(Z,'ColorThreshold',cutoff); % 系統樹を作成
Col = vertcat(d.Color);
[or, ~, idx] = unique(Col, 'rows')
or = 4×3
0 0 0 0 0 1 0 1 0 1 0 0
idx = 29×1
3 4 4 4 3 4 4 4 2 3
%配色を設定
newcolors = hsv(4)
newcolors = 4×3
1.0000 0 0 0.5000 1.0000 0 0 1.0000 1.0000 0.5000 0 1.0000
%設定した配色に変更
for k = 1:size(or, 1)
arr = idx==k;
set(d(arr), 'Color', newcolors(k, :))
end
  1 Commento
Dyuman Joshi
Dyuman Joshi il 18 Nov 2023
There are 3 groups in the gscatter() whereas there are 4 groups in the dendrogram().
Which groups from the dendrogram should be similar to the gscatter? The bottom three (cyan, magenta and green lines in the above plot) ?

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Behavior and Psychophysics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!