Colormap with both positive and negative values
Show older comments
Hi all,
I have a very simple issue, but the solution has been escaping me nonetheless.
I have a big matrix of correlations: some are negative and some are positive. I would like to plot them with a red-green colormap (like the "colormap(redgreencmap)" for "imagesc"). In this map, a correlation of -1 should be bright red, a correlation of +1 bright green and a correlation of close to zero black.
However, it seems like MATLAB can only handle matrices of values between [0,1] for colormap plotting.
This should be pretty simple, but I cannot figure out the solution. Does anyone have any suggestions?
Thanks a lot,
Anders
Accepted Answer
More Answers (1)
Walter Roberson
on 7 Jul 2013
0 votes
The colormap should always be the RGB values to use, not the data values that are to be mapped into RGB values.
Create your colormap with bright red in the lower-numbered rows, black in the middle rows, and bright green in the last rows, and then imagesc() your data that is in the range -1 to +1
2 Comments
Jason McCune-Sanders
on 9 Nov 2017
How would one easily change the shading of the map, i.e. add more colors or reduce the black zone in the middle? Thanks!
Walter Roberson
on 9 Nov 2017
Categories
Find more on White 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!