利用 annotation 命令实现图形的标注

在利用matlab作图时,经常需要对图形进行标注,例如标注坐标值、箭头、主题等。利用textlegend可以实现该功能,但当拉伸图形窗口时,标注的位置会发生变化。而 annotation 是相对于坐标轴定位,使用该组件的标注不会发生变化。

标注类型
类型参数
意义
'line'
直线
'arrow'
箭头
'doublearrow' 双箭头
'textarrow' 带有文本框的箭头
'textbox' 文本框
'ellipse' 椭圆
'rectangle' 矩形

例程如下:

% 创建一个球,使用地质颜色映射表
cla reset;
load topo;
[x y z] = sphere(45);
s = surface(x, y, z, 'facecolor', 'texturemap', 'cdata', topo);
colormap(topomap1);
% 增强显示颜色亮度
brighten(.6)
campos([2 13 10]);
camlight;
lighting gouraud;
axis off vis3d;
x = [0.7698 0.5851];% 设置箭头文本框的位置信息
y = [0.3593 0.5492];
% 创建箭头文本对象
txtar =  annotation('textarrow', x, y,'LineWidth', 2,'Color', 'r','string', '文本标记','FontSize', 12);


你可能感兴趣的:(利用 annotation 命令实现图形的标注)