Plot in matlab with imagesc with different range colors in colorbar/colormap
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alban Kita
el 17 de Abr. de 2019
Respondida: Alban Kita
el 17 de Abr. de 2019
Hello to everybody.
I am trying to have an image plot with imagesc with different range colors. I explain myself.
The code is the following:
load Corr_matrix_IMS_All_Riordinato_Uncorrelated.txt
imagesc(Corr_matrix_IMS_All_Riordinato_Uncorrelated)
colormap(gray(4))
colorbar
caxis([-0.55 1]);
I enclose here the figure i obtain.
I need 4 colours in gray scale with the following limits [-0.55 0], [0 0.5], [0.5 0.9], [0.9 1]. Matlab makes 4 colours but just divides equally the colours range, like the picture enclosed.
I googled a lot but it was not really helpful.
I hope somebody can handle this.
Thank you very much in advance.
Best regards,
Alban Kita
0 comentarios
Respuesta aceptada
Walter Roberson
el 17 de Abr. de 2019
You need to create a color map as follows:
rows 1 to 11: 0 0 0
rows 12 to 21: 1/3 1/3 1/3
rows 22 to 29: 2/3 2/3 2/3
rows 30 to 31: 1 1 1
Each row covers a span of 0.05 in original value. So row 1 covers -.55 to -.50, row 2 covers -0.50 to -.45, row 3 covers -0.45 to -0.40, and so on. But it is okay that those are separate slots in the colormap, because they are assigned the same color.
You will also need to imagesc(YourArray, [-0.55 1])
just in case the array has slightly different contents that does not exactly match the boundaries you set out.
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre White en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!