MATLAB Answers

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

1 view (last 30 days)
Emily
Emily on 18 Apr 2019
Commented: Emily on 18 Apr 2019
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!!!

  0 Comments

Sign in to comment.

Accepted Answer

Rylan Dmello
Rylan Dmello on 18 Apr 2019
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

More Answers (0)

Sign in to answer this question.

Tags

Products


Release

R2018b