値の変動を色で表現するグラフの作成方法

22 views (last 30 days)
denpika
denpika on 2 Aug 2017
Commented: denpika on 2 Aug 2017
添付ファイル上図のような波形の動きを下図のような 色スケールの変化で表せるようなグラフを作成したいのですが、 どのような方法があるでしょうか? サンプルグラフは1を赤、-1を緑にしています。 色の設定方法なども教えていただけると助かります。
  2 Comments
michio
michio on 2 Aug 2017
下記例は patch オブジェクトの色を明示的に指定していますが、一例まで。
他のサンプルプロットはこちらから: MATLAB Plot Gallery
denpika
denpika on 2 Aug 2017
ご回答ありがとうございます。参考にさせていただきます。

Sign in to comment.

Accepted Answer

Jiro Doke
Jiro Doke on 2 Aug 2017
Edited: Jiro Doke on 2 Aug 2017
色スケールは surface コマンドで無理やり作ってみました。例として既定のカラーマップ(parula)を使用しましたが、実際のスケール(1が赤で-1が青、その間は?)が分かれば簡単に変更できると思います。
% データ定義
x = 0:360;
y1 = cos(x*pi/180);
y2 = sin(x*pi/180);
% ラインプロット
subplot(4,1,1:3)
plot(x,y1,x,y2)
set(gca,'XAxisLocation','origin')
xlim([0 360])
box off
legend('系列1','系列2')
% 色スケール
subplot(4,1,4)
surface(0:360,0:1,[y1;y1])
surface(0:360,-1:0,[y2;y2])
shading interp
text(0,0.5,'系列1','HorizontalAlignment','right','VerticalAlignment','middle')
text(0,-0.5,'系列2','HorizontalAlignment','right','VerticalAlignment','middle')
xlim([0 360])
axis off
  1 Comment
denpika
denpika on 2 Aug 2017
ご回答ありがとうございます。お陰様で解決しそうです。

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!