How to set colour on 3d graph depending on data

I am currently working on random plane waves and I am trying to interpolate data in 3D. I have my interpolating polynomial F and I plot it using surf(F) command. My graph (when looking at xy plane)looks as follows
The thing is, I am not particularly interested in the actual values, but just positive/negative values. The question is - how can I set my graph to colour all positive values with one colour (black, say) and negative with another (white, for instance)?
I used colormapeditor so far and changed it manually (just to trace the results) but now when I need to produce 20 separate results it becomes too laborious.
Many thanks

Answers (1)

Adam
Adam on 20 Jan 2017
Edited: Adam on 20 Jan 2017
cmap = [1 1 1; 0 0 0];
colormap( hAxes, cmap )
You will also need to make sure you have a symmetric colour axis though using
doc caxis
e.g.
dataMax = max( abs( myData(:) ) );
caxis( hAxes, [-1 1] .* dataMax )
Or if you don't want to have to mess about with caxis, just change the data you plot and make it all +1 or -1, then your colourmap will be symmetric by default.

Asked:

on 20 Jan 2017

Edited:

on 20 Jan 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!