I am trying to create a map similar to the one below, except each polygon needs to be colored corresponding to a single value.
So far, I have created the polygons and included sample values in the structures. Is there a way to create a colorbar for each polygon facecolor corresponding to each 'sampleNum'?
Sample code:
latZone1 = [25, 25, 50, 50, 25];lonZone1 = [-105, -125, -125, -105, -105];zone1Poly = geoshape(latZone1, lonZone1, 'sampleNum', 89);zone1Poly.Geometry = 'polygon';latZone2 = [25, 25, 40, 40, 25];lonZone2 = [-100, -105, -105, -100, -100];zone2Poly = geoshape(latZone2, lonZone2, 'sampleNum', 63);zone2Poly.Geometry = 'polygon';latZone3 = [40, 40, 50, 50, 40];lonZone3 = [-100, -105, -105, -100, -100];zone3Poly = geoshape(latZone3, lonZone3, 'sampleNum', 45);zone3Poly.Geometry = 'polygon';latZone4 = [25, 25, 35, 35, 25];lonZone4 = [-95, -100, -100, -95, -95];zone4Poly = geoshape(latZone4, lonZone4, 'sampleNum', 78);zone4Poly.Geometry = 'polygon';latZone5 = [35, 35, 40, 40, 35];lonZone5 = [-95, -100, -100, -95, -95];zone5Poly = geoshape(latZone5, lonZone5, 'sampleNum', 70);zone5Poly.Geometry = 'polygon';latZone6 = [40, 40, 50, 50, 40];lonZone6 = [-95, -100, -100, -95, -95];zone6Poly = geoshape(latZone6, lonZone6, 'sampleNum', 25);zone6Poly.Geometry = 'polygon';states = geoshape(shaperead('usastatehi', 'UseGeoCoords', true));figure('Visible','on');hold onax = usamap([25 50],[-125 -65]);geoshow(states,'FaceColor', 'w')geoshow(zone2Poly, 'LineWidth', 1,'FaceColor','k')geoshow(zone1Poly, 'LineWidth', 1,'FaceColor','r')geoshow(zone3Poly, 'LineWidth', 1,'FaceColor','b')geoshow(zone4Poly, 'LineWidth', 1,'FaceColor','b')geoshow(zone5Poly, 'LineWidth', 1,'FaceColor','r')geoshow(zone6Poly, 'LineWidth', 1,'FaceColor','g')
Any help is greatly appreciated!
Best Answer