フィルターのクリア

Changing colors using imagesc

31 ビュー (過去 30 日間)
Haneya Qureshi
Haneya Qureshi 2018 年 3 月 23 日
コメント済み: Haneya Qureshi 2018 年 3 月 23 日
I have large matrix M whose elements take the values of either 1, 0 or -1. I am using imagesc(M) but I want to plot green color where there is 1, red color where there is 0 and white color where there is -1 in the matrix. How can I do this?

採用された回答

Adam
Adam 2018 年 3 月 23 日
編集済み: Adam 2018 年 3 月 23 日
Create your own colourmap, e.g
data = round( 2 * ( rand(20) - 0.5 ) );
figure; hAxes = gca;
imagesc( hAxes, data );
colormap( hAxes , [1 1 1; 1 0 0; 0 1 0] )
  1 件のコメント
Haneya Qureshi
Haneya Qureshi 2018 年 3 月 23 日
This is just perfect! Exactly what I need! Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by