【问题标题】:Matlab GUI axes to figureMatlab GUI 轴图
【发布时间】:2014-10-29 18:45:32
【问题描述】:

我有一个带有一些轴的 Gui。 现在我将把一个轴放在一个新的数字上。 这是我的代码:

h = handles.axes3; % Find the axes object in the GUI
f1 = figure % Open a new figure with handle f1
s = copyobj(h,f1); % Copy axes object h into figure f1
print(f1,'-dpsc', 'raspberry.eps');

这可行,但窗口的大小与图不同。 我认为 GUI 中的轴不在新图中的轴 1 上?

【问题讨论】:

    标签: matlab matlab-guide


    【解决方案1】:

    您复制的是坐标轴,而不是图形。

    创建一个新图形将创建一个默认大小的图形 - 这与handles.axes3 的祖先(图形)大小不同。

    请看下面的例子:

    f = figure ( 'position', [100 100 200 200] );
    h = axes ( 'position', [0 0 0.5 0.5], 'parent', f );
    
    % This will create a figure with a different size
    f1 = figure ( 'Name', 'Different Size Fig' );
    copyobj ( h, f1 );
    
    % copy a figure which has the same size as the original
    hFig = ancestor ( h, 'figure' );
    originalFigPos = get ( hFig, 'position' );
    f2 = figure ('Name', 'Same Size Fig' );
    newFigPos = get ( f2, 'position' );
    newFigPos(3:4) = originalFigPos(3:4);
    set ( f2, 'position', newFigPos );
    
    s = copyobj ( h, f2 );
    

    【讨论】:

      猜你喜欢
      • 2014-09-03
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      • 2018-11-30
      • 2012-06-23
      • 1970-01-01
      • 2014-02-13
      相关资源
      最近更新 更多