Borrar filtros
Borrar filtros

Changing colors using imagesc

31 visualizaciones (últimos 30 días)
Haneya Qureshi
Haneya Qureshi el 23 de Mzo. de 2018
Comentada: Haneya Qureshi el 23 de Mzo. de 2018
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?

Respuesta aceptada

Adam
Adam el 23 de Mzo. de 2018
Editada: Adam el 23 de Mzo. de 2018
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 comentario
Haneya Qureshi
Haneya Qureshi el 23 de Mzo. de 2018
This is just perfect! Exactly what I need! Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by