필터 지우기
필터 지우기

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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by