MATLAB text的“关键字”

来源:互联网 发布:超星慕课刷课软件 编辑:程序博客网 时间:2024/06/05 19:36

一、ColorSpec  定义颜色,本身并非关键字

  RGB Value  Short Name  Long Name
  [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

说明:使用RGB格式的话直接使用即可,使用ShortName/LongName还需要加' ',另外RGB格式除了整数值以外还可用浮点数,所以颜色更丰富。

eg:set(gcf,'Color',[1,1,0])  = set(gcf,'Color','y')

  …………'BackgroundColor',[.7 .9 .7] …………

  …………

 

二、HorizontalAlignment  /  VerticalAlignment  文本对齐方式

  HorizontalAlignment 的值有  'left','center','right'

  VerticalAlignment的值有  top | cap | {middle} | baseline |  bottom,加''用,{}表示默认

 

三、BackgroundColor  背景颜色,值参考(一)  需要命令二

 

四、 Edgecolor  边框颜色,值参考(一)

 

五、LineStyle  线形  需要命令四

  SymbolLine     Style
    -       Solid line (default) 实线
    --      Dashed line 虚线
    :       Dotted line 点线
    -.       Dash-dot line 虚点线
    none     No line 没线

 

六、LineWidth  线宽  大于0标量值,默认为1,不加引号用  需要命令四

 

七、Margin  边缘宽度  大于0标量值,默认貌似为1,不加引号用  需要命令二

 

八、Rotation  旋转角度  标量值,默认0,角度制,可以为负

 

九、Position  定位  默认定位左下角,但若设定了对齐方式则按照对齐方式,如果之前定位过,那么position后就变为position的,[x y (z)],z默认为0

 

十、string  与 Interpreter  latex | {tex} | none 的设定相关,当设定为前两个时,可以使用一系列的特殊字符,特点是用 开头。

bf — Bold font

it — Italic font

sl — Oblique font (rarely available)

rm — Normal fontfontname{fontname} —Specify the name of the font family touse.

fontsize{fontsize} —Specify the font size in FontUnits.

color(colorSpec) —Specify color for succeeding characters

 

eg:

figure;axis([-10,10,-10,10]);
text(3*pi/10,sin(3*pi/10),...   %这里定义了一次位置,按照默认的左下角对齐
 ['sin(3*pi/4) = ',num2str(sin(3*pi/4))],...
 'HorizontalAlignment','left',...
    'VerticalAlignment','top',...   %这两条命令指定了左上角对齐(默认左下)
 'BackgroundColor',[0,1,1],...   %背景色
    'margin',1,...  %边缘宽,默认1
    'Edgecolor',[1 0 0],... 边框色,默认没有边框
    'Linewidth',2,...   %线宽,默认1
    'linestyle',':',... %线形,默认实线
    'rotation',0,...    %旋转角,默认0,角度制
    'position',[2 4]);  %又定义了一次位置,按照设定的左上角对齐

text('Interpreter','latex',...
 'String','$$int_0^x!int_y dF(u,v)$$',... %string 和$必须要
 'Position',[-5 -5],...
 'FontSize',16)
   
text(-5,5,['fontsize{16}itblack {color{magenta}rmmagenta '...
'color[rgb]{0 .5 .5}bfteal color{red}slred} black again'])

原创粉丝点击