[转载]matlab画图之text用法
2017-06-04 18:03阅读:
text命令可以让我们在图上做标记,作出简单的说明,类似于图例的功能,但不止于图例。下面是matlab中的text命令的语法:
- text(x,y,'string')
在2D图形中指定的位置(x,y)上显示字符串string
- text(x,y,z,'string')
在3D图形中指定的位置(x,y,z)上显示字符串string
- text(x,y,z,'string','PropertyName',PropertyValue....)
- text('PropertyName',PropertyValue....)
- 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:
常用的颜色表示:
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')也能恢复。