![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176502/image.jpeg)
Problem with Color Coded Map
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
While trying to create a color coded map of the United States, I've come across multiple instances where a state ends up miscolored. I've provided an example of my issue below.
Here, I'm assigning each state's color based on the "Data" field. For all states other than Texas I assign a value of 1.15, with Texas being assinged a value of 1.07. If I understand the code correctly, Texas should display as dark blue while the other states should display as light blue. Instead, all states display as light blue, even though the value for Texas falls within the dark blue range. What am I missing here?
ax = usamap('conus');
states = shaperead('usastatehi', 'UseGeoCoords', true,...
'Selector', {@(name) ~any(strcmp(name,{'Alaska','Hawaii'})), 'Name'});
for i = 1:numel(states)
if strcmp(states(i).Name,'Texas')
states(i).Data = 1.07;
else
states(i).Data = 1.15;
end
end
faceColors = makesymbolspec('Polygon',...
{'Data', [1 1.5], 'FaceColor', jet(5)});
geoshow(ax, states, 'DisplayType', 'polygon', 'SymbolSpec', faceColors)
framem off; gridm off; mlabel off; plabel off
caxis([1 1.5])
colormap(jet(5))
colorbar
0 Commenti
Risposte (1)
Omar Elsayed
il 26 Mag 2017
I think the problem is in the value you assigned for Texas. When I changed 1.07 to 1 I got this map.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/176502/image.jpeg)
0 Commenti
Vedere anche
Categorie
Scopri di più su Blue in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!