天天看點

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

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('你的文本');% 可以自己選擇将文本放在何處

繼續閱讀