How to assign figure property with movegui() on Matlab subplot?

杀马特。学长 韩版系。学妹 提交于 2019-12-23 05:47:19

问题


I need to assign the units inches for subplots (1-2). I added movegui() for the figure, after which I started to get the error. Without it, I donot get the error message. Code

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';

Error

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

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

Matlab: 2016a
OS: Debian 8.5 64 bit


回答1:


I cannot reproduce your error, but if you want to assign the units for specific subplots, then assign it explicitly for them rather than relying on hFig3.Children to return the subplots in a particular order. You can do this by passing an array of axes to set.

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

Or if you really want to use dot notation you can do them individually

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

Or you can just set this when they are created

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


来源:https://stackoverflow.com/questions/39815844/how-to-assign-figure-property-with-movegui-on-matlab-subplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!