Array of +1s and -1s: Want Pink and Blue for imagesc

조회 수: 1 (최근 30일)
Emily
Emily 2019년 4월 18일
댓글: Emily 2019년 4월 18일
I have a 2-dim array of just +1's and -1s. I am using imagesc(myarray) and I want it to appear with the +1's showing up as a bring pink and the -1's showing up as blue. Does anyone have any suggestions? Thank you!!!

채택된 답변

Aylin
Aylin 2019년 4월 18일
Hi Emily, the colormap function might work for you:
% Generate some sample data.
data = 2 * randi([0 1], 10, 10) - 1;
% Define the color map. Normalize 0-255 RGB values to 0-1 intensities.
map = [255, 20, 147;
0,191, 255] / 255;
% Plot data and set the new colormap on the current figure.
imagesc(data)
colormap(map)
This generates the following image:
cmap.png

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 White에 대해 자세히 알아보기

태그

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by