如何在Matlab子图上用movegui()赋值图属性?

时间:2016-10-02 10:02:20

标签: matlab matlab-figure subplot

我需要为子图(1-2)分配单位 inches 。 我为该图添加了 movegui(),之后我开始收到错误。 没有它,我不会收到错误消息。 代码

hFig3=figure('Units', 'inches', 'Name', 'Time, Potential, T-p, T-p tiff');
movegui(hFig3,'northeast'); % without this, you do not get the error
% TechnicalMonitoring
b1=subplot(2,2,1); 
b2=subplot(2,2,2); 
b3=subplot(2,2,3); 
b4=subplot(2,2,4); 

% b1, b2 
hFig3.Children(1).Units = 'inches';
hFig3.Children(2).Units = 'inches';

错误

No public property Units exists for class matlab.graphics.GraphicsPlaceholder.

Error in code_1s (line 488)
    hFig3.Children(1).Units = 'inches';

Matlab:2016a
操作系统:Debian 8.5 64位

1 个答案:

答案 0 :(得分:1)

我无法重现您的错误,但如果您想为特定子图分配单位,请为其明确指定,而不是依赖hFig3.Children按特定顺序返回子图。您可以通过将axes数组传递给set来完成此操作。

set([b1 b2], 'Units', 'inches')

或者,如果你真的想使用点符号,你可以单独进行

b1.Units = 'inches';
b2.Units = 'inches';

或者你可以在创建时设置它

subplot(2, 2, 1, 'Units', 'Inches');