MATLAB: How do you change the contourf color at specific level

contourf

Hello,
I'm trying to plot a 2D contour plot with caxis ranging from -1 to 1. I want to set the contourf color for 0 to be white. How do I do that? Here is a working example of what I am trying to do
x=linspace(-1,1,11);
y=x;
[x,y]=meshgrid(x,y);
z=x;
levs=-1.1:0.2:1.1;
contourf(x,y,z,levs)
How do I get the color corresponding to z = -0.1 to 0.1 to be white instead of green, so that the filled contour at centered at 0 is white.
I'm using version Matlab 2015b.

Best Answer

Answered my own question:
[C,h]=contourf(x,y,z,levs)
index=6; % levs=-0.1 at levs(6)
rgba = double(cat(2, h.FacePrims.ColorData))./255;
col = rgba(1:3,:)';
col(index,:)=ones(size(col(index,:))); % [1 1 1] is the RGB color code for white
colormap(col)
Problem solved! Used the link cited for the answer