plotを使用してグラフの色をデータに応じて変更する方法
25 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
yuto tamura
le 10 Avr 2020
Réponse apportée : yuto tamura
le 11 Avr 2020
line関数を使用して2点を結ぶ直線を引き, それぞれの対応する値により直線の色を変更する方法がわかりません.
scatter関数のように値でグラフの色を変更できる方法を知りたいです.
例)
x y 番号
1 1 1
5 4 2
10 5 3
20 10 4
のようなデータの組があり,
それぞれの点を結ぶ組み合わせで対応する値がありその値により直線の色を変更するプログラムがわかりません.
組み合わせ 値
1-2 0.1
1-3 0.7
1-4 0.01
1-5 0.007
すみませんが, よろしくお願いいたします.
0 commentaires
Réponse acceptée
Akira Agata
le 11 Avr 2020
以下のように、グラフオブジェクトを構築・可視化する方法はいかがでしょうか?
% データ点の(x,y)座標
x = [1,5,10,20];
y = [1,4,5,10];
% Edgeの始点(s),終点(t),重み(w)
% ※注:組み合わせのうち "1-5" については対応するデータ点がないため除去しました。
s = [1,1,1]';
t = [2,3,4]';
w = [0.1,0.7,0.01]';
% グラフを構築
G = graph(s,t);
% 可視化
figure
plot(G,'XData',x,'YData',y,'EdgeCData',w,'LineWidth',2,'MarkerSize',8);
colorbar
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur 2 次元および 3 次元プロット dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!