![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1042660/image.png)
How to fill polygons based on attribute values?
20 次查看(过去 30 天)
显示 更早的评论
I have used the following code to load and plot the shapefile "Expot.shp" (attaced zip file). I wanted to plot the "Corr" attribute, but for some reason the colour does not match the values. (Also, the "Corr" values with zeros are basically not calculated - can treat them as NaNs)
landAreas = readgeotable("landareas.shp"); %from "geoshow" matlab documentation
row = landAreas.Name == "North and South America";
landAreasSubset = landAreas(row,:);
corr = shaperead("Expot.shp")
cmap = jet(256);
colorRange = makesymbolspec("Polygon", ...
{'Corr',[-0.02 0.05],'FaceColor',cmap}); %Use makesymbolspec to specify polygon colors
mapshow(corr,"SymbolSpec",colorRange)
colormap(cmap)
caxis([-0.02 0.05])
colorbar
hold on
geoshow(landAreasSubset)
The result map is attached below
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1042530/image.jpeg)
The legend shows the "Corr" values but the map does not. I'd like to know where I seem to be going wrong; I think there's a line of code missing or needs to be changed.
I'd be grateful for assistance on this. Thank You
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!