0

I have an nc file with lat, lon and ice_conc. I wish to plot the sea ice concentration on a square grid (which the script does) in shades of white instead of yellow and have the open ocean in blue. Here's what I have:

silo=ncread('ice_conc_201707031200_v2.nc','lon');
sila=ncread('ice_conc_201707031200_v2.nc','lat');
si=ncread('ice_conc_201707031200_v2.nc','ice_conc');

F = scatteredInterpolant(silo',sila',si');

[lox,lay] = meshgrid(-80:0.05:80,-70:0.05:-20);

sii = F(lox,lay);
sii(isnan(sii))=0;

set(groot,'defaultAxesTickLabelInterpreter','latex');  
set(groot,'defaulttextinterpreter','latex');
set(groot,'defaultLegendInterpreter','latex');

close all
ax1 = axes; 

contourf(ax1,lox,lay,sii/100,'LineColor','none'); % do I plot colormap in white for 100% seaice down 
to blue for 0% sea ice??

grid on, axis equal, xlim([10 50]), ylim([-70 -30])

enter image description here

Bacol
  • 3
  • 2

1 Answers1

1

One way would be to create your own colormap. Below is a possible example:

cmap = colormap(); % your current colormap

n = size(cmap, 1)/2; % change only the second half of the colormap
col = cmap(n, :); % color at the halfway point

for i = 1:3
    % For example linearly interpolate the color between the one at the halfway point and white
    cmap(n:end, i) = linspace(col(i), 1, length(cmap(n:end, i)));
end

contourf(...) % your plot
colormap(cmap) % apply the colormap
Matteo V
  • 1,163
  • 1
  • 8
  • 17