Editing colors in a colormap

조회 수: 7 (최근 30일)
Shivani Patel
Shivani Patel 2019년 1월 28일
댓글: Shivani Patel 2019년 1월 29일
In my code, I'm using the imagesc function to create a changing colormap as a movie. I have created a manual map that goes from the white to black scale. However, there are certain parts of the colormap that I would like to manually make a color that does not fall in the white to black range, such as blue. I need to do this within my code, so that the code can capture the image as a frame. How would I accomplish this?
Thank you.

답변 (1개)

Adam
Adam 2019년 1월 28일
How do you have your colourmap currently? If you have it as an e.g. 256x3 matrix of colours then you can just set e.g.
myColourmap( 100,: ) = [0 0 1];
to make the 100th index colour blue.
  댓글 수: 1
Shivani Patel
Shivani Patel 2019년 1월 29일
map = [0 0 0
0.1 0.1 0.1
0.2 0.2 0.2
0.3 0.3 0.3
0.4 0.4 0.4
0.5 0.5 0.5
0.6 0.6 0.6
0.7 0.7 0.7
0.8 0.8 0.8
0.9 0.9 0.9
1 1 1];
% g1 to g17 change for each iteration and can range from 0-1
M=[g1 g2; g3 g4; g5 g6; g7 g8; g9 g10; g11 g12; g13 dum; g14 dum; g15 dum; g16 dum; g17 dum];
imagesc(M)
colormap(map)
caxis([0 1]);
frame = getframe(gcf);
For each variable 'dum' I need it to be manually set to a single color (that is not in the white to black range) so that it can be distinguishable. I'm still unsure as to how to do this.
Thanks.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by