필터 지우기
필터 지우기

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 CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by