変数に応じてplotの色を変更する方法
51 views (last 30 days)
Show older comments
ある変数に応じて2次元プロットの色を変更する方法を教えてください。
例えば、あるGPSの軌跡X(緯度)、Y(経度)のデータと、その時の加速度Zのデータがあります。
X,Yのデータをプロットして、走行軌跡を表示させるときに、
Zの値が+(加速)の時は赤、ー(減速)の時は青といったプロットをしたいです。
また、Zがー(減速)の時のプロットの数はいくつか、自動で算出させたいです。
初心者なので申し訳ありませんが、よろしくお願いします。
2 Comments
Accepted Answer
Atsushi Ueno
on 26 Jan 2024
Moved: Atsushi Ueno
on 26 Jan 2024
上記は説明用で、単に2次元でプロットしたいなら下記でOKです。
t = 0:0.01:99.99;
x = sin(2*t);
y = cos(3*t);
z = (sin(8*t) > 0) * 2 - 1;
scatter(x,y,5,z,'filled');
colormap([1,0,0; 0,0,1]);
3 Comments
More Answers (0)
See Also
Categories
Find more on Orange 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!