Borrar filtros
Borrar filtros

Problem with Color Coded Map

2 visualizaciones (últimos 30 días)
Brandon
Brandon el 2 de Nov. de 2016
Respondida: Omar Elsayed el 26 de Mayo de 2017
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

Respuestas (1)

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

Categorías

Más información sobre Blue en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by