How do I specify a specific color for a specific value when using the colormap?
Show older comments
I have a matrix that I would like to plot using imagesc. I have done this and then used one of the standard colormaps (jet, summer, etc.). My matrix is a 75x75 matrix and the matrix consist of only five different values that I would like to plot in five specific colors.
For example -1 = blue, 3 = green, 4 = grey, 5 = Brown and 10 = red.
I have only managed to create a range of colors by using the standard colormaps (ranging from blue to red for example). I tried to create my own colormap, however I could only involve three different colors. When I tried to involve four colors I received an error saying that there was something wrong with my dimensions.
In Excel this is very simple and I guess it's the same in Matlab and that I'm missing something very basic here?
2 Comments
Geoff Hayes
on 23 Aug 2018
Robin - how did you construct your custom colormap? Something like
customColormap = [0 0 1; 0 1 0; 0.5 0.5 0.5; 0.5 0 0; 1 0 0];
Robin
on 24 Aug 2018
Accepted Answer
More Answers (0)
Categories
Find more on Color and Styling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!