这里有一个更新版本的代码的例子:
%地图美国包括阿拉斯加和夏威夷
%地图美国阿拉斯加和夏威夷的单独的轴。
图
ax = usamap (“所有”);
集(ax,“可见”,“关闭”)
州= shaperead (“usastatelo”,“UseGeoCoords”,真正的);
名称= {states.Name};
%指数
indexHawaii = strcmp (“夏威夷”、名称);
indexAlaska = strcmp (“阿拉斯加”、名称);
statesSubset1 = {“伊利诺斯州”,德州的};%编辑这个列表
指数= cellfun (@ (x) strcmp (x,名字),statesSubset1,“UniformOutput”、假);
indicesSubset1 ={1}指数;
为我= 2:元素个数(指数)
indicesSubset1 = indicesSubset1 |指标{};
结束
indexConus = 1:元素个数(州);
indexConus (indexHawaii | indexAlaska | indicesSubset1) = [];
%的颜色
stateColor1 = (0.5 - 1 0.5);%根据需要编辑颜色
stateColor2 = (1 0 0);
stateColor3 = (0 0 1);
%显示三个区域。
geoshow (ax(1),状态(indexConus),“FaceColor”stateColor1)
geoshow (ax(1),状态(indicesSubset1),“FaceColor”stateColor2)
geoshow (ax(2),状态(indexAlaska),“FaceColor”stateColor3)
geoshow (ax(3),状态(indexHawaii),“FaceColor”stateColor3)
%隐藏框架。
为k = 1:3
setm (ax (k),“帧”,“关闭”,“网格”,“关闭”,…
“ParallelLabel”,“关闭”,“MeridianLabel”,“关闭”)
结束
你应该能够适应这段代码到您的用例。
- 您可以添加更多的子集。
- 你可以更新细节哪个国家应该属于哪个子集。
- 您还可以将不同的颜色分配给每个子集。