Skip to Main Content Skip to Search
Accelerating the pace of engineering and science

 

Newsletters - MATLAB Digest

Direct Color Mapping and colorscale

The following script plots global NDVI using direct color mapping and colorscale. It uses many of the workspace variables assigned in the main body of the article. A sea surface temperature swath is superposed over the NDVI image as a MATLAB surface, using a different part of the colormap.

figure('Renderer','zbuffer')
colormap([sstCmap; ndviCmap])
image(ndviMapped,'XData',[-179.5 179.5],'YData',[89.5 -89.5])
set(gca,'YDir','normal','DataAspectRatio',[1 1 1],...
  'XTick',-180:30:180,'YTick',-90:30:90,...  % Ticks every 30 degrees
  'XLim',[-180 180],'YLim',[-90 90])         % Axes limits in degrees
xlabel('Longitude, degrees')
ylabel('Latitude, degrees')
title('SST swath plotted over one-degree NDVI grid')
surface(sstLon, sstLat, ones(size(sstLon)), double(sstMapped) + 1,...
  'Linestyle','none','CDataMapping','Direct'); % Add color scales
pos = get(gca,'Position');
set(gca,'Position',pos + [0 0.13 0 0])
colorscale(ndviCmapLim, ndviDataLim, 0.2, 'horiz',...
  'Position',[pos(1) 0.22 pos(3) 0.03])
ylabel('NDVI') colorscale(sstCmapLim, sstDataLim, 5, 'horiz',...
  'Position',[pos(1) 0.1 pos(3) 0.03]) ylabel('SST')
xlabel('degrees Celcius')
Contact sales
Subscribe to newsletters