フィルターのクリア

Problem with Color Coded Map

1 回表示 (過去 30 日間)
Brandon
Brandon 2016 年 11 月 2 日
回答済み: Omar Elsayed 2017 年 5 月 26 日
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

回答 (1 件)

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

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by