Effacer les filtres
Effacer les filtres

Problem with Color Coded Map

2 vues (au cours des 30 derniers jours)
Brandon
Brandon le 2 Nov 2016
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

Réponses (1)

Omar Elsayed
Omar Elsayed le 26 Mai 2017
I think the problem is in the value you assigned for Texas. When I changed 1.07 to 1 I got this map.

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by