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:
automatically maximizing figures

Subject: automatically maximizing figures

From: Tom

Date: 5 Nov, 2008 10:39:00

Message: 1 of 12

Hi there,
i'am using ML 7.5 on Windows XP SP3 here. To maximize the figures on
screen i use:

scrsz = get(0,'ScreenSize')
which gets me:
1 1 1280 1024
and then
set(0,'DefaultFigurePosition', [scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);

which worked fine before, but on my new pc the figure bottom isn't
placed on the screen bottom, but rather somewhere in the middle.

To match the bottoms i have to set the bottom value to ~ -80.

Why is that and how can i fix this without manually adjusting (the
script should work on several pc with diff. resolutions)?
Or maybe theres another (better) method?

TIA
Tom

Subject: automatically maximizing figures

From: Rune Allnor

Date: 5 Nov, 2008 10:54:42

Message: 2 of 12

On 5 Nov, 11:39, Tom <tom....@yahoo.com> wrote:
> Hi there,
> i'am using ML 7.5 on Windows XP SP3 here. To maximize the figures on
> screen i use:
>
> scrsz =3D get(0,'ScreenSize')
> which gets me:
> 1 =A0 =A0 =A0 =A0 =A0 1 =A0 =A0 =A0 =A01280 =A0 =A0 =A0 =A01024
> and then
> set(0,'DefaultFigurePosition', [scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);
>
> which worked fine before, but on my new pc the figure bottom isn't
> placed on the screen bottom, but rather somewhere in the middle.
>
> To match the bottoms i have to set the bottom value to ~ -80.
>
> Why is that and how can i fix this without manually adjusting (the
> script should work on several pc with diff. resolutions)?
> Or maybe theres another (better) method?

Apart from comparing the numbers with what pops out from

get(0,'monitorposition');

I can only suggest to try and use normalized units:

set(0,'units','normalized');
set(0,'defaultfigureposition',[0 0 1 1]);

Rune

Subject: automatically maximizing figures

From: Tom

Date: 5 Nov, 2008 11:32:00

Message: 3 of 12

Rune Allnor wrote:
> On 5 Nov, 11:39, Tom <tom....@yahoo.com> wrote:
>> Hi there,
>> i'am using ML 7.5 on Windows XP SP3 here. To maximize the figures on
>> screen i use:
>>
>> scrsz = get(0,'ScreenSize')
>> which gets me:
>> 1 1 1280 1024
>> and then
>> set(0,'DefaultFigurePosition', [scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);
>>
>> which worked fine before, but on my new pc the figure bottom isn't
>> placed on the screen bottom, but rather somewhere in the middle.
>>
>> To match the bottoms i have to set the bottom value to ~ -80.
>>
>> Why is that and how can i fix this without manually adjusting (the
>> script should work on several pc with diff. resolutions)?
>> Or maybe theres another (better) method?
>
> Apart from comparing the numbers with what pops out from
>
> get(0,'monitorposition');
>
This gives me the same values as for screensize.

> I can only suggest to try and use normalized units:
>
> set(0,'units','normalized');
> set(0,'defaultfigureposition',[0 0 1 1]);

Did you tried this? It doesn't work here, seems to me that normalized
units aren't accepted for defaultfigureposition. instead the figures are
really small (and >> menu doesn't work at all)...

Any other ideas?


PS:
Maybe this bug occurs because i use a notebook in a docking station.
however i use only the "big" screen, the notebook is closed.

Subject: automatically maximizing figures

From: Stephan

Date: 5 Nov, 2008 11:33:01

Message: 4 of 12

Hi there

I had the same problem. I deleted the line 110 in openfic.m, which is

movegui(fig(n), 'onscreen');

now it's working fine.

Cheers Stephan

Subject: automatically maximizing figures

From: Rune Allnor

Date: 5 Nov, 2008 16:10:06

Message: 5 of 12

On 5 Nov, 12:32, Tom <tom....@yahoo.com> wrote:
> Rune Allnor wrote:

> > Apart from comparing the numbers with what pops out from
>
> > get(0,'monitorposition');
>
> This gives me the same values as for screensize.
...
> Maybe this bug occurs because i use a notebook in a docking station.
> however i use only the "big" screen, the notebook is closed.

Ah. There's your problem.

I use a notebook with both the default screen and a stand-alone
add-on screenl i.e a dual-screen setup. When I query for monitor
sizes I get

>> get(0,'MonitorPosition')

ans =

           1 1 1680 1050
       -1439 1 0 900

which means that the stand-alone screen is of a different
size than the laptop screen. This is probably the case with
your screens as well, but since you use the stand-alone as
a primary screen, the system gets it wrong since it is the
laptop screen which is registered with the OS.

Rune

Subject: automatically maximizing figures

From: Tom

Date: 5 Nov, 2008 17:26:48

Message: 6 of 12

Stephan wrote:
> I had the same problem. I deleted the line 110 in openfic.m, which is
>
> movegui(fig(n), 'onscreen');
>
> now it's working fine.
>
I guess you mean openfig.m, however, it doesn't change anything here...

Subject: automatically maximizing figures

From: Tom

Date: 5 Nov, 2008 17:40:15

Message: 7 of 12

Rune Allnor wrote:
> On 5 Nov, 12:32, Tom <tom....@yahoo.com> wrote:
>> Rune Allnor wrote:
>>> Apart from comparing the numbers with what pops out from
>>> get(0,'monitorposition');
>> This gives me the same values as for screensize.
> ...
>> Maybe this bug occurs because i use a notebook in a docking station.
>> however i use only the "big" screen, the notebook is closed.
>
> Ah. There's your problem.
>
> I use a notebook with both the default screen and a stand-alone
> add-on screenl i.e a dual-screen setup. When I query for monitor
> sizes I get
>
>>> get(0,'MonitorPosition')
>
> ans =
>
> 1 1 1680 1050
> -1439 1 0 900
>
> which means that the stand-alone screen is of a different
> size than the laptop screen. This is probably the case with
> your screens as well, but since you use the stand-alone as
> a primary screen, the system gets it wrong since it is the
> laptop screen which is registered with the OS.
>
Hmm, i don't think so, because in Windows display settings only one
screen is activated and >> get(0,'MonitorPosition') get me only one and
the right vector.

However, how did you solve the problem?

TIA
Tom

Subject: automatically maximizing figures, it's all messed up

From: Tom

Date: 6 Nov, 2008 11:21:15

Message: 8 of 12

Tom wrote:
> Hi there,
> i'am using ML 7.5 on Windows XP SP3 here. To maximize the figures on
> screen i use:
>
> scrsz = get(0,'ScreenSize')
> which gets me:
> 1 1 1280 1024
> and then
> set(0,'DefaultFigurePosition', [scrsz(1) scrsz(2) scrsz(3) scrsz(4)]);
>
> which worked fine before, but on my new pc the figure bottom isn't
> placed on the screen bottom, but rather somewhere in the middle.
>
> To match the bottoms i have to set the bottom value to ~ -80.
>
> Why is that and how can i fix this without manually adjusting (the
> script should work on several pc with diff. resolutions)?
> Or maybe theres another (better) method?
>
> TIA
> Tom

Aaargh, nothing is working fine anymore!

Even if I manually adjust the default figure position to:
set(0,'DefaultFigurePosition', [scrsz(1) -80 scrsz(3) scrsz(4)]);

the figures are looking "ok" on screen, but when i print them to pdf
they are cutted at top and bottom. ;-(

A check of the Position (before printing):
 >> get(gcf,'Position')
ans =
            1 -17 1280 961

why isn't it the values I specified before (1 -80 1280 1024)?

It's all messed up!!


Now i tried with:
set(gcf,'PaperUnits','normalized')
set(gcf,'PaperPosition', [0 0 1 1])
to adjust the position in the pdf, which works fine at a first glance,
but the legends aren't placed correctly. But if i insert
set(gcf,'PaperPositionMode','auto')
afterwards the figure are cutted again ...

Ahh, can someone help me please!

TIA
tom

Subject: automatically maximizing figures

From: Jan Simon

Date: 6 Nov, 2008 11:22:01

Message: 9 of 12

Hi Tom!

> scrsz = get(0,'ScreenSize')
> set(0,'DefaultFigurePosition', scrsz);

This does not work as expected on Matlab5, 6, 7.7. Even the direct creation of a figure "fails":
  figure('Position', scrsz);
Setting the default figure units to normalized does not help also: While the width seems to work, the height of the figure is reduce by the height of the menubar and upper window border.

Do you want to adjust the outer position? Does the FEX script showwindow help you, which can maximize a figure after creation (after a certain PAUSE(0.1) time delay...)?

On the other hand: The java interface should be so powerful to set the figure size exactly! Unfortuantely, I do not know the needed command.

Good luck, Jan

Subject: automatically maximizing figures

From: Tom

Date: 7 Nov, 2008 16:51:33

Message: 10 of 12

Jan Simon wrote:
> Hi Tom!
>
>> scrsz = get(0,'ScreenSize')
>> set(0,'DefaultFigurePosition', scrsz);
>
> This does not work as expected on Matlab5, 6, 7.7. Even the direct creation of a figure "fails":
> figure('Position', scrsz);
> Setting the default figure units to normalized does not help also: While the width seems to work, the height of the figure is reduce by the height of the menubar and upper window border.
>
> Do you want to adjust the outer position? Does the FEX script showwindow help you, which can maximize a figure after creation (after a certain PAUSE(0.1) time delay...)?
>
> On the other hand: The java interface should be so powerful to set the figure size exactly! Unfortuantely, I do not know the needed command.
>
> Good luck, Jan

Hi Jan,
after figuring out what "FEX script showwindow" means (and checking it
out), I decided to use "Figure window placement"
(http://www.mathworks.com/matlabcentral/fileexchange/9035) instead,
because the handling is IMHO better.

So my figures are now maximized on screen without any problems, but in
the pdf they are still cropped...

Why is that?

Is this maybe a problem only in my version (R2007b)?

If I use:
set(gcf,'PaperPositionMode','auto')
set(gcf,'PaperUnits','normalized')
set(gcf,'PaperPosition', [0 0 1 1])

output is not cropped, but legend is not placed correctly

If:
set(gcf,'PaperUnits','normalized')
set(gcf,'PaperPosition', [0 0 1 1])
set(gcf,'PaperPositionMode','auto')

output is cropped, but legend is placed correctly.


There should be a way to save figures to pdf, without any influences of
the figure window?


I'am thankfully for any help
Tom

Subject: automatically maximizing figures

From: Jan Simon

Date: 8 Nov, 2008 23:51:02

Message: 11 of 12

Dear Tom!

Did you see Matlab's "movegui" command?

Look at Print_PDF in FEX:
http://www.mathworks.com/matlabcentral/fileexchange/22018

The general approach to print a EPS at first and call GhostScript for the conversion to a PDF works perfectly for me (you need the GhostScript at first from www.ghostscript.com, on Windows the executable is "...\gsX.YZ\bin\gswin32c.exe" depending on your installation):

set(FigH, 'ResizeFcn', '', 'PaperPositionMode', 'manual');
printf(FigH, '-dpsc2', '-r300', 'temp.ps');
system([GhostScript_executable, ' ', ...
  '-q -dNOPAUSE -dBATCH -dFIXMEDIA -sDEVICE=pdfwrite ', ...
  '-sPaperSize=a4 -sOutputFile="test.pdf" ', ...
  '-c save pop -f "temp.ps"']);

This is the core of what Print_PDF is doing, so just try it instead of the above piece of code.

Good luck, Jan

Subject: automatically maximizing figures

From: Tom

Date: 10 Nov, 2008 11:02:08

Message: 12 of 12

Hello Jan,

Jan Simon wrote:
> Did you see Matlab's "movegui" command?
Sorry, but i can't see how this should help me...

>
> Look at Print_PDF in FEX:
> http://www.mathworks.com/matlabcentral/fileexchange/22018
>
> The general approach to print a EPS at first and call GhostScript for the conversion to a PDF works perfectly for me (you need the GhostScript at first from www.ghostscript.com, on Windows the executable is "...\gsX.YZ\bin\gswin32c.exe" depending on your installation):
>
I print to ps as well and then i use ps2pdf (FEX) to create a multi-page
pdf with several figures, so print_pdf is no option for me. but thanks
anyway.

I found out that on another pc with ML 2008a, no such problems occur, so
i will try now updating next.

Tags for this Thread

No tags are associated with 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