主要内容

本页采用了机器翻译。点击此处可查看英文原文。

northarrow

在基于 axesm 的地图上添加北向箭头

语法

northarrow
northarrow('property',value,...)

说明

northarrow 创建默认的指北针。

northarrow('property',value,...) 使用指定的属性/值对创建指北针。属性有效输入为 'latitude''longitude''facecolor''edgecolor''linewidth''scaleratio''latitude''longitude' 属性指定了北箭头的方位位置。'facecolor''edgecolor''linewidth' 属性控制指北针的外观。'scaleratio' 属性表示北箭头的大小占坐标区大小的比例。当 'scaleratio' 值设为 0.10 时,将生成一个大小为坐标区十分之一(1/10)的指北针。您可以使用 set 命令更改指北针的外观('facecolor''edgecolor''linewidth')。

northarrow 函数在显示地图的地图原点处创建一个指北针符号。您可以通过点击并拖动北箭头图标来重新定位它。或者,通过右键点击或按住 Ctrl 并用左键点击箭头,打开一个对话框,用于更改北箭头的方位。无论您将符号移动到何处,北箭头的方向都会自动计算,无需手动调整。

修改北箭头的某些属性会导致原始对象被替换。使用 HANDLEM('NorthArrow') 获取与北箭头关联的句柄。

示例

全部折叠

绘制一张德克萨斯州地图。在地图左下角添加北箭头。

figure
usamap("texas")
states = readgeotable("usastatelo.shp");
faceColors = makesymbolspec("Polygon",...
         {'INDEX',[1 numel(states)],'FaceColor',polcmap(height(states))});
geoshow(states,"DisplayType","polygon","SymbolSpec",faceColors)
northarrow("Latitude",25,"Longitude",-105,"LineWidth",1.5);

Figure contains an axes object. The hidden axes object contains 19 objects of type patch, line, text.

更改指北针的边框和填充颜色。

h = handlem("NorthArrow");
set(h,"FaceColor",[1 0.8431 0],"EdgeColor",[0.01 0.01 0.9])

Figure contains an axes object. The hidden axes object contains 19 objects of type patch, line, text.

创建以南极点为中心的地图。在指定地理位置添加指北针。

GT = readgeotable("landareas.shp");
antarctica = GT(GT.Name == "Antarctica",:);
figure
worldmap("south pole")
geoshow(antarctica)
northarrow("latitude",-57,"longitude",135);

Figure contains an axes object. The hidden axes object contains 22 objects of type patch, line, text.

更改北箭头的外观。

h = handlem("NorthArrow");
set(h,"FaceColor", [1.000 0.8431 0.0000], ...
      "EdgeColor", [0.0100 0.0100 0.9000])

Figure contains an axes object. The hidden axes object contains 22 objects of type patch, line, text.

通过再画三支北箭,证明从南极出发的每个方向都是北。请注意,北箭头是坐标区中的对象,采用笛卡尔坐标系,而非映射对象。因此,若创建多个指北针,任何操作指北针的 Mapping Toolbox™ 函数都仅会影响最后绘制的那个。

northarrow("latitude",-57,"longitude", 45);
northarrow("latitude",-57,"longitude",225);
northarrow("latitude",-57,"longitude",315);

Figure contains an axes object. The hidden axes object contains 28 objects of type patch, line, text.

限制

您可以在地图上绘制多个指北针。然而,回调函数仅对最近创建的指北针有效。此外,由于指北针可显示在地图边框之外,因此不会将其转换为“映射”对象。因此,当地图原点或投影发生变化时,必须手动更新北箭头的方位和方向。

版本历史记录

在 R2006a 之前推出

另请参阅