MATLAB Answers

0

Create a specular colormap

Asked by Maria445 on 15 Mar 2019
Latest activity Edited by Adam
on 15 Mar 2019
I'm using the patch function with a "hot" colormap.
However, I'd like the colormap to be specular; namely I'd like it to be centered on zero and have the same color for positive and negative values with the same absolute value.
Is it possible to do it?

  0 Comments

Sign in to comment.

Products


Release

R2018b

1 Answer

Adam
Answer by Adam
on 15 Mar 2019
Edited by Adam
on 15 Mar 2019
 Accepted Answer

figure; imagesc( rand(100) - 0.5 ); % Random data centred on 0
baseCmap = hot( 256 );
cmap = [ flip( baseCmap(2:end,:) ); baseCmap ];
colormap( cmap )
caxis( [-0.5 0.5] )

  1 Comment

Maria445 on 15 Mar 2019
Thank you a lot!

Sign in to comment.