MATLAB: How to change the facecolor of each grid in a map

colormappingMapping Toolboxtoolbox

I would like to know how to change the facecolor of each grid in a map.

Best Answer

You can change the FACECOLOR property as shown in the example below:
[filename,pathname]=uigetfile('*.shp','Select the shape file for plotting');
cd(pathname);
shape=shaperead(filename);
%X_poly={shape.X}';
%Y_poly={shape.Y}';
lat=[shape.LAT]';
lon=[shape.LON]';
pop=[shape.Pop2000]';
gas=[shape.GasSt]';
%plot data
h=mapshow(shape,'FaceColor','r');
face_color=get(h,'FaceColor');
for i=1:1000
face_color{i,1}=[0 1 0];
end
for i =1001:2000
face_color{i,1}=[1 1 0];
end
PropName = {'Facecolor'};
set(h,PropName,face_color);