Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Industries Academia Support User Community Company

 

Newsletters - MATLAB Digest

Scaled Color Mapping and colorbar

The following script plots global NDVI using scaled color mapping and the colorbar function in MATLAB. The script uses many of the workspace variables assigned in the main body of the article.

figure
colormap(ndviCmap)
i = imagesc(ndvi,ndviCodelim);
set(i,'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('NDVI from AVHRR, July 1-10, 2001')
pos = get(gca,'Position'); % Save axes position % Add colorbar
h = colorbar('horiz');
label = sprintf('NDVI / %.3f + %.0f', ndviScaleFactor, ndviAddOffset);
set(get(h,'XLabel'),'String',label)
set(gca,'Position',pos + [0 0.075 0 0]) % Put axes where we want it
set(h,'Position',[pos(1:3) 0.05])       % Put colorbar where we want it
Contact sales
E-mail this page
Print this page
Subscribe to newsletters