分類器アプリ内の散布図を自分で作る方法を教えてください
Show older comments
分類器アプリ内の「散布図」を自分でも作りたのですが,やり方がわかりません.
データは分類器へインポートする形です.
応答子は3種類あります.応答子ごとに色を変えて2つの変数を散布図で表す方法を教えてください.
ファイル添付しております.
よろしくお願いします.
2 Comments
Hiro Yoshino
on 20 Feb 2024
(tabledata.mat の中身が全て "1" でしたが合っていますか?)
Tadafumi Sugi
on 21 Feb 2024
Answers (1)
scatter 関数かなと思いますが、いかがでしょうか?:
a = rand(20,2);
b = rand(20,2);
scatter(a(:,1),a(:,2));
hold on
scatter(b(:,1),b(:,2));
legend("a","b");
6 Comments
Tadafumi Sugi
on 21 Feb 2024
Tadafumi Sugi
on 21 Feb 2024
Tadafumi Sugi
on 21 Feb 2024
こんな感じはどうでしょうか?
- tiledlayout - 複数 axes 配置
- nexttile - 次の axis 配置
- colormap - カラーマップ取得
X = randn(20,3); % サンプルデータ
Y = randn(20,3); % サンプルデータ
tiledlayout("flow");
cmap = colormap(); % 異なる色を用意
for k=1:3
nexttile
scatter(X(:,k),Y(:,k),[],cmap(80*k,:));
title(sprintf("scatter #%d",k));
end
Tadafumi Sugi
on 22 Feb 2024
forループを使用して、ラベル毎に分けた散布図を作成してみました。
load('tabledata.mat');
labels = unique(x.Label); %使用されているラベルの一覧を作成
figure;
for i = 1 : length(labels)
data = x(x.Label == labels(i), :); % テーブルデータから選択したラベルを持つデータを抽出
scatter(data.Av_Ave, data.Av_AveCross, 'DisplayName', labels(i)); % 散布図作成
hold on;
end
legend;
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

