您的位置:首页 > 编程语言 > MATLAB

matlab(figure和subplot)title text figure标题的使用技巧

2016-05-03 16:38 731 查看
1、修改figure标题

h=figure(1);

set(h,'name','your text','Numbertitle','off');

2、text用法

text(10,10,'your text');% 前面两个位置坐标

如果要在text中输入变量,那么

text(10,10,sprintf('这是第%d幅图像(变量i);\n程序运行时间(变量time):%2.2f秒;\n占用百分比:%d%%(变量p);',i,time,p*100));

3、figure区别于子图(subplot)之外的title

 

第①种方法 :

fig = figure;

   a(1) = subplot(2,2,1);

   p(1) = plot(rand(10,1));title('1');

   a(2) = subplot(2,2,2);

   p(2) = plot(rand(10,1));title('2');

   a(3) = subplot(2,2,3);

   p(3) = plot(rand(10,1));title('3');

   a(4) = subplot(2,2,4);

   p(4) = plot(rand(10,1));title('4');

   ax = axes('position',[0,0,1,1],'visible','off');

   tx = text(0.4,0.95,'第一种方法');

   set(tx,'fontweight','bold');

第②种方法:

subplot(122);% 在子图后面添加以下内容

ax = axes('position',[0,0,1,1],'visible','off');

tx = text(0.18,0.05,'第二种方法');

set(tx,'fontweight','bold');

 

第③种方法:

figure;uicontrol('Style','text','String', '第三种方法','Units','normalized','Position', [0.5 0.2 0.1 0.1]);% 修改text句柄

或者

subplot(122);% 在子图后面添加以下内容

ah=gca;axes('position',[0,0,1,1],'visible','off');text(.5,.25,'第三种方法'');axes(ah);

3、gtext用法不多叙述,很简单

figure;gtext('你的文本');% 可以自己选择将文本放在何处
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息