- /
-
U.S.A.! U.S.A.!
on 16 Oct 2024
- 10
- 108
- 0
- 0
- 937
Cite your audio source here (if applicable): https://pixabay.com/ja/music/the-star-spangled-banner-231193/
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent patchs
if f == 1
% Settings
names = {'Conus', 'Alaska', 'Hawaii'};
states = readgeotable('usastatelo.shp');
states = {states([1 3:10 12:51],:), states(2,:), states(11,:)};
txtPos = {[0.54 0.37], [0.24 0], [0.7 0]};
mapPos = {[-0.21 0.14], [-0.1 -0.27], [0.72 0.06]};
% Plot
fig = figure('Position', [0 0 600 600]);
annotation(fig, 'line', [0 1], [0.55 0.2]);
annotation(fig, 'line', [0.63 0.63], [0.33 0]);
ax = usamap("all");
for i = 1 : 3
annotation(fig, 'textbox', [txtPos{i} 0.2 0.09], ...
'String', names{i}, 'EdgeColor', 'none', ...
'FontName', 'Times New Roman', 'FontSize', 30);
setm(ax(i), 'Frame', 'off', 'Grid', 'off', ...
'ParallelLabel', 'off', 'MeridianLabel', 'off');
ax(i).Position = 1.7 * ax(i).Position; % Scale
ax(i).Position(1:2) = mapPos{i}; % Move
g = geoshow(ax(i), states{i}, 'DisplayType', 'polygon');
patchs = [patchs g.Children(:)'];
end
end
if mod(f, 8) == 1
cmap = colormap('turbo');
X = randi(256, 51, 1);
arrayfun(@(i) set(patchs(i), 'FaceColor', cmap(X(i), :)), 1:51);
end
end