Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:31:03+00:00 2026-05-31T04:31:03+00:00

Similar to: Setting graph figure size But, I just want to set the width

  • 0

Similar to: Setting graph figure size

But, I just want to set the width and height, without caring about the position. The desired behavior is that I can drag the figure around at will, but on each re-draw the size will be fixed.

I don’t like the method in the above link because you must provide an (x,y) coordinate for the position, which is annoying as the code develops or I use different computers. But perhaps there is a smarter way to use that set() function?

EDIT: Cool @ answer below, here’s my updated function. The other thing is to be “silent” so the figure doesn’t pull focus constantly.

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:31:04+00:00Added an answer on May 31, 2026 at 4:31 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many similar questions to this one, but they all ask about setting
I can't resolve this issue, I found a similar question here but: setting the
I've been thinking about setting up a image grid similar to milliondollarhomepage for a
Following on from this question about setting Culture, I have a similar issue with
Similar questions to this my have been asked a lot of times before. But
Similar to the question Bitshift and integer promotion? , I have a question about
Similar to this question asking about relatively light-weight data entry / editor application development,
I am setting lots of properties with a series of set calls e.g. this.set('prop1',
I want to test that setting a certain property (or more generally, executing some
Does ipython have a setting similar to '-e' in bash that stops the execution

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.