向图中添加注释 您所在的位置:网站首页 matlab在图上加文字 向图中添加注释

向图中添加注释

2023-04-09 17:06| 来源: 网络整理| 查看: 265

注释的类型

使用 annotation 函数可以向图中添加注释。函数的第一个输入指定要创建的注释的类型。

如果将类型指定为 'line'、'arrow'、'doublearrow' 或 'textarrow',则第二个输入是注释的起点和终点 x 位置。第三个输入是注释的起点和终点 y 位置。例如,annotation('line',[x_begin x_end],[y_begin y_end])。

如果将类型指定为 'rectangle'、'ellipse' 或 'textbox',则第二个参数是位置和大小。例如,annotation('rectangle',[x y w h])。

注释使用归一化的图窗单位,并且可以在一个图窗中跨越多个坐标区。

创建简单的图

定义和绘制函数 f(x) 和 g(x)。

x = -3.0:0.01:3.0; f = x.^2; g = 5*sin(x) + 5; figure plot(x,f) hold on plot(x,g) hold off

圆圈注释

在图中添加一个圆圈,以突出显示 f(x) 等于 g(x) 的位置。要创建圆圈,请使用 'ellipse' 选项作为注释类型。

通过设置底层对象的属性来自定义圆圈。将 Ellipse 对象作为 annotation 函数的输出参数返回。然后,使用圆点表示法访问对象的属性。例如,设置 Color 属性。

elps = annotation('ellipse',[.84 .68 .05 .05])elps = Ellipse with properties: Color: [0 0 0] FaceColor: 'none' LineStyle: '-' LineWidth: 0.5000 Position: [0.8400 0.6800 0.0500 0.0500] Units: 'normalized' Show all properties elps.Color = [0 0.5 0.5];

文本箭头注释

使用 'textarrow' 选项作为注释类型,向图中添加一个文本箭头。

您可以通过设置底层对象的属性来自定义文本箭头。将 TextArrow 对象作为 annotation 函数的输出参数返回。然后,使用圆点表示法访问对象的属性。例如,将 String 属性设置为所需的文本,将 Color 属性设置为颜色值。

ta = annotation('textarrow', [0.76 0.83], [0.71 0.71])ta = TextArrow with properties: String: {''} FontName: 'Helvetica' FontSize: 10 Color: [0 0 0] TextColor: [0 0 0] LineStyle: '-' LineWidth: 0.5000 HeadStyle: 'vback2' Position: [0.7600 0.7100 0.0700 0] Units: 'normalized' X: [0.7600 0.8300] Y: [0.7100 0.7100] Show all properties ta.String = 'f(x) = g(x) '; ta.Color = [0 0.5 0.5];



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有