Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Maximise a figure

Subject: Maximise a figure

From: Jane T

Date: 20 May, 2011 17:50:08

Message: 1 of 6

Hi,

I have some code that generates a Figure with several subplots and a textbox in each subplot. All of this is done from within a script file.

If I maximise my Figure after the fact then the textboxes don't transpose properly and the Figure looks ugly. Therefore I want to create and then maximise a figure window before writing to it.

I found the code
warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
h = figure;
jFrame = get(h,'JavaFrame') ;
set(jFrame,'Maximized',1);

On the web. Although it works fine when invoked from the command window, when embedded in an m-file it just causes a load of errors.

Is anyone able to help me create and then maximize a figure in an m-file? I'm using version 2011a.

Many thanks

Subject: Maximise a figure

From: ImageAnalyst

Date: 20 May, 2011 18:41:00

Message: 2 of 6

The official Mathworks recommendation is to use "maxfig" which is
located on their web site.
http://www.mathworks.com/support/solutions/en/data/1-3MY8PN/?solution=1-3MY8PN

Then put this code in your outputFcn function (if you're using GUIDE):

% Call special function that The Mathworks gave me to maximize the
window and leave it in focus.
% minfig(F,1) % minimizes the figure window for the figure with
handle F
% minfig(F,0) % restores figure F if F is minimized
% maxfig(F,1) % maximizes the figure window for the figure with
handle F
% maxfig(F,0) % restores figure F if F is maximized s = figstate(F)
% returns the state of figure { Maximized | Minimized | Normal }
% Note: This works only if the window is already displayed. If not,
it will throw a java exception.
% The best place to put this is in the yourApp_OutputFcn(),
% which actually gets called as the last thing before your app is
made available to the user.
maxfig(handles.figMainWindow, 1) % Maximizes the figure window for
the figure with handle in the first argument.

Subject: Maximise a figure

From: Jane T

Date: 20 May, 2011 20:25:09

Message: 3 of 6

Thanks, maxfig works well :D

Subject: Maximise a figure

From: Jane T

Date: 20 May, 2011 20:30:22

Message: 4 of 6

On first glance maxfig does exactly what I was after, however...

maxfig maximizes the figure, but dispite being the first line or so in the m-file it doesn't seem to apply it until after the figures and textboxes have been filled; the textboxes still aren't in the correct alignment.

However, if I put a breakpoint after the maxfig statement then it all works great.

Any suggestions?

Many thanks

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <99749d2c-180c-48fa-8475-289182e9e503@w21g2000yqm.googlegroups.com>...
> The official Mathworks recommendation is to use "maxfig" which is
> located on their web site.
> http://www.mathworks.com/support/solutions/en/data/1-3MY8PN/?solution=1-3MY8PN
>
> Then put this code in your outputFcn function (if you're using GUIDE):
>
> % Call special function that The Mathworks gave me to maximize the
> window and leave it in focus.
> % minfig(F,1) % minimizes the figure window for the figure with
> handle F
> % minfig(F,0) % restores figure F if F is minimized
> % maxfig(F,1) % maximizes the figure window for the figure with
> handle F
> % maxfig(F,0) % restores figure F if F is maximized s = figstate(F)
> % returns the state of figure { Maximized | Minimized | Normal }
> % Note: This works only if the window is already displayed. If not,
> it will throw a java exception.
> % The best place to put this is in the yourApp_OutputFcn(),
> % which actually gets called as the last thing before your app is
> made available to the user.
> maxfig(handles.figMainWindow, 1) % Maximizes the figure window for
> the figure with handle in the first argument.

Subject: Maximise a figure

From: ImageAnalyst

Date: 20 May, 2011 21:30:35

Message: 5 of 6

If maxfig is the first line in the m-file, what is there to maximize?

Things may not scale unless their 'Units' property is set to
'normalized' - I doubt you've done that.

Subject: Maximise a figure

From: Jane T

Date: 20 May, 2011 21:57:04

Message: 6 of 6

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <8588da91-b23e-49b6-a2ed-c12f6dcf3969@h7g2000yqa.googlegroups.com>...
> If maxfig is the first line in the m-file, what is there to maximize?
>
> Things may not scale unless their 'Units' property is set to
> 'normalized' - I doubt you've done that.

I did so first line or so, it's actually the second line, directly after h=figure;

Normalized units!!! Man that saves so much phaffing and guess work, plus it eliminates my scaling problem :D

Many thanks

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us