Search code examples
matlabplotsurfacecolormap

Stabilizing the colormap range to compare two surface plot diagrams in Matlab


Whatever I tried I couldn't stabilize the colors of two diagrams. When the values decrease from 0 - 30 to 0-1 the colormap always adapts to new values. In the figures attached, I need to stabilize the first color scale 0-30, and second legend should by all dark blue as well as the surface.

Disregard the y-values.

0-30 0-1

Thank you so much for all your help and advices.

The partial code is below.

args = {time,freq,abs(cfs).^2}; 
surf(args{:},'edgecolor','none'); 
view(0,90); axis tight; 
shading interp; colormap(parula(128)); 
h = colorbar;  

I tried this but didn't work.

set(h,'ylim',[0 100]); 
yal=linspace(1,100);
set(h,'ytick',yal); 

Solution

  • Try adding this instead:

    caxis([0 100]);
    

    https://www.mathworks.com/help/matlab/ref/caxis.html