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 datah=mapshow(shape,'FaceColor','r');face_color=get(h,'FaceColor');for i=1:1000 face_color{i,1}=[0 1 0];endfor i =1001:2000 face_color{i,1}=[1 1 0];endPropName = {'Facecolor'};set(h,PropName,face_color); Related SolutionsMATLAB: How to change color in barh graph You modify the 'FaceColor' of the bar:h = barh(rand(4,2),'stacked')h(1).FaceColor = 'r'; % colorh(2).FaceColor = [0.3 0.78 0.1];% rgb MATLAB: Is it possible to summarize this code You could use a switch case structure, that would be a bit more compact.it would look like this:switch davar1.CC_CHECK case 'New York' p(1).FaceColor = 'g'; case 'California' p(1).FaceColor = 'y'; case 'Illinois' p(1).FaceColor = 'r'; case 'Texas ' p(1).FaceColor = 'k'; case 'Ohio' p(1).FaceColor = 'b'; % powder pink case 'North Carolina' p(1).FaceColor = 'c'; case 'Tennessee' p(1).FaceColor = 'w';end Related QuestionFind area of the filled region of a graphHow to get the facecolor of each barFind vertices and plot triangle in Matlab
Best Answer