MATLAB, 기본 그림 크기를 설정하지만 위치에 대해 신경 쓰지 마십시오.

StackOverflow https://stackoverflow.com//questions/9650056

문제

유사 그래프 설정 크기

그러나 위치에 대해 돌보지 않고 너비와 높이 을 설정하고 싶습니다.원하는 행동은 내가 그림을 끌 수 있지만 각각의 다시 그리는 크기가 수정 될 수 있다는 것입니다.

코드가 개발하거나 다른 컴퓨터를 사용하는 것으로 짜증나는 위치에 대해 (x, y) 좌표를 제공해야하기 때문에 위의 링크에서 방법을 좋아하지 않습니다.그러나 아마도 그 세트 () 함수를 사용하는 것이 더 똑똑한 방법이 있습니까?

편집 : 아래 cool @ 답변, 여기에 내 업데이트 된 기능이 있습니다.다른 일은 "침묵"이기 때문에 그림이 끊임없이 초점을 맞추지 않는 것입니다.

function h = sfigure(h,s1,s2)
% SFIGURE  Create figure window (minus annoying focus-theft).
%
% Usage is identical to figure.
%
% Daniel Eaton, 2005
%
% See also figure
%
% Modified by Peter Karasev, 2012, to optionally set scale
%

if nargin>=1 
    if ishandle(h)
        set(0, 'CurrentFigure', h);
    else
        h = figure(h);
    end
else
    h = figure;
end

if( nargin > 1 )
  scaleX = s1;
  scaleY = s1;
  if( nargin > 2 )
    scaleY = s2;
  end
  pos = get(h,'Position');
  pos(3:4) = [400 300].*[scaleX scaleY];
  set(gcf,'Position',pos);
end
.

도움이 되었습니까?

해결책

Combine it with the corresponding get function:

figure
pos = get(gcf,'Position');
pos(3:4) = [w h];
set(gcf,'Position',pos);

This will keep the default position and only change the width and height.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top