zoukankan      html  css  js  c++  java
  • Matlab绘图基础——给图像配文字说明(text对象)

     
    text对象
    (1)text(x坐标,y坐标,'string')在图形中指定位置(x,y)显示字符串string。
    (2)Editing有效值为on/off,off时,用户在执行GUI操作时无法直接在该Text对象上进行编辑,改为on后,可以进行编辑。
    (3)HorizontalAlign 有效值为left/center/right决定Text对象中字符水平方向的对齐方式。
    (4)Interpreter有效值为tex/none,决定Text对象中是否可用Tex字符注释,当设置为Tex时,表示允许用户能够在String属性下输入Tex字符。以下为在窗口的 [.5 .5]点位置处建立一个text对象并且字体大小以16点来表示的一个方程式。(显示的是一个二重积分)
     text('interpreter','latex','string','$$int_0^x!int_y dF(u,v)$$','position',[.5 .5],'fontsize',16)
    (5)String有效值为字符串,表示要显示出来的字符串是什么。
    (6)verticalAlignme 有效值为top/cap/middle/baseline/bottom决定Text对象垂直对齐的方
    式。

    小技巧

    str = char( zeros(n,1)+'*' ); % 复制某一字符串n次

    % 直方图的标注

    % 数据准备
    y = randn(1,100);
     
    % 绘制直方图
    h = histogram(y,'Normalization','probability');
    h.BinWidth = 0.5;  % 修改组间距
    axis(gca,[floor(min(y)) ceil(max(y)) 0 max(h.Values+0.05)]);
     
    set(gca,'XTick',floor(min(y)):.5:ceil(max(y)));     %设置x轴的坐标范围及间隔
    set(gca,'YTick',0:.05:max(h.Values+0.05));     %设置x轴的坐标范围及间隔
    % 标注直方图
    for i=1:h.NumBins
       if h.Values(i)==0,continue;end
       str=sprintf('%4.2f',h.Values(i));   % 2位小数的浮点型text
       text(h.BinEdges(i)+0.075,h.Values(i)+0.0075,str);
    end
  • 相关阅读:
    nyist 287 Redar
    nyist 14 会场安排问题
    nyist 90 整数分割
    nyist 123 士兵杀敌四
    nyist 116 士兵杀敌
    nyist 277 车牌号
    nyist 590 相同的和
    寄宿于WindowsService的WebAPI
    C#Dictionary 字典、泛型
    Repository模式
  • 原文地址:https://www.cnblogs.com/stxs/p/8641303.html
Copyright © 2011-2022 走看看