MATLAB Answers

1

symmetric color map using surf

Asked by Peter Wagner on 6 Mar 2019
Latest activity Commented on by Peter Wagner on 7 Mar 2019
Hi there,
I would like to show in a graph a symmetric color driving from 0 green to either + and - to red. The peak at the bottom should be in colour yellow again.
All areas around 0 in green. Anyone an Idea? Cheers
AddColorbarToGraphExample_01.png

  2 Comments

Make your colormap data and try..read bout colormap
Thanks! colormap worked!

Sign in to comment.

1 Answer

Answer by Akira Agata
on 7 Mar 2019
 Accepted Answer

Like this?
cmap = interp1([-1;0;1],[1 0 0;0 1 0;1 0 0],linspace(-1,1)');
surf(peaks)
colormap(cmap)
colorbar
surf.png

  1 Comment

very nice code! code

Sign in to comment.