新浪博客

[转载]matlab画图之text用法

2017-06-04 18:03阅读:
原文作者:5Geo

text命令可以让我们在图上做标记,作出简单的说明,类似于图例的功能,但不止于图例。下面是matlab中的text命令的语法:
  1. text(x,y,'string') 在2D图形中指定的位置(x,y)上显示字符串string
  2. text(x,y,z,'string') 在3D图形中指定的位置(x,y,z)上显示字符串string
  3. text(x,y,z,'string','PropertyName',PropertyValue....)
  4. text('PropertyName',PropertyValue....)
  5. h = text(...)
ProperrtyName:属性名字,字符的一些修饰性的东西
以矩形边框为例
BackgroundColor —矩形边框的背景颜色 (none by default)
EdgeColor — 矩形边框的颜色 (none by default)
LineStyle — 矩形边框的线条形式(是虚线还是点线还是。。。。)(first set EdgeColor)
LineWidth — 矩形边框的宽度 (first set EdgeColor

Margin
边沿

PropertyValue 属性值
命令:
plot(0:pi/20:2*pi,sin(0:pi/20:2*pi))
text(3*pi/4,sin(3*pi/4),'leftarrowsin(t) = .707','EdgeColor','red');
Fig:
[转载]matlab画图之text用法


常用的颜色表示:
RGB Short Long
[1 1 0] y yellow
[1 0 1] m magenta 品红
[0 1 1] c cyan 青色
[1 0 0] r red
[0 1 0] g green
[0 0 1] b blue
[1 1 1] w white
[0 0 0] k black

whitebg([0 1 0]); whitebg('g'); whitebg('green');
note:如果使用上面的命令时,画布背景颜色可能你就不知道怎么调回来,使用 colordef white这个就可以恢复画布的默认的背景颜色了,或者妮使用whitebg('white')也能恢复。

我的更多文章

下载客户端阅读体验更佳

APP专享