Thread Subject: figure size in pixels?

Subject: figure size in pixels?

From: David Doria

Date: 19 Apr, 2008 14:32:02

Message: 1 of 6

I want to save a figure to a file with a particular size in
pixels. I do this:

figure('units','pixels','outerposition',[0 0 800 450]);
set(gcf,'PaperPositionMode','auto');
print('-djpeg', filename);

but the resulting file is 1237x575!!

What have I done wrong?

Thanks,

Dave

Subject: figure size in pixels?

From: French Caro

Date: 19 Apr, 2008 14:49:02

Message: 2 of 6

"David Doria" <daviddoria@gmail.com> wrote in message
<fucvp1$4rl$1@fred.mathworks.com>...
> I want to save a figure to a file with a particular size in
> pixels. I do this:
>
> figure('units','pixels','outerposition',[0 0 800 450]);
> set(gcf,'PaperPositionMode','auto');
> print('-djpeg', filename);
>
> but the resulting file is 1237x575!!
>
> What have I done wrong?
>
> Thanks,
>
> Dave
HI
I think you should use Position property no Outerposition
(which is an axes property at least, I can't find it in
figure properties)

Subject: figure size in pixels?

From: David Doria

Date: 19 Apr, 2008 15:30:05

Message: 3 of 6

figure('units','pixels','Position',[100 100 800 450]);
%[left bottom width height]

%subplot position is relative to the figure and hence
doesn't change anything about the previous command, correct?
LeftPlot = subplot('Position', [0 .1 .5 .8]); %[left bottom
width height]

set(gcf,'PaperPositionMode','auto');
print('-djpeg', filename);

the files produced are now 1249x704!! what the heck??

Thanks,

Dave

Subject: figure size in pixels?

From: David Doria

Date: 19 Apr, 2008 16:38:02

Message: 4 of 6

Turns out there is an m file on the file exchange called

saveSameSize.m that does exactly what I needed.

If anyone still has a simple explanation of why it didn't
work the way I did it I'll still take it haha!

Subject: figure size in pixels?

From: Joaquim Luis

Date: 19 Apr, 2008 17:24:02

Message: 5 of 6

"David Doria" <daviddoria@gmail.com> wrote in message
<fud75a$onq$1@fred.mathworks.com>...
> Turns out there is an m file on the file exchange called
>
> saveSameSize.m that does exactly what I needed.
>
> If anyone still has a simple explanation of why it didn't
> work the way I did it I'll still take it haha!

Maybe you want to read the comments inside my imcapture.m
which likely would have done the job as well.

http://www.mathworks.com/matlabcentral/fileexchange/
loadFile.do?objectId=13355&objectType=FILE

J. Luis

Subject: figure size in pixels?

From: Dan Haeg

Date: 20 Apr, 2008 17:22:01

Message: 6 of 6

"Joaquim Luis" <jluis@--ualg--.pt> wrote in message
<fud9ri$d1h$1@fred.mathworks.com>...
> "David Doria" <daviddoria@gmail.com> wrote in message
> <fud75a$onq$1@fred.mathworks.com>...
> > Turns out there is an m file on the file exchange called
> >
> > saveSameSize.m that does exactly what I needed.
> >
> > If anyone still has a simple explanation of why it didn't
> > work the way I did it I'll still take it haha!
>
> Maybe you want to read the comments inside my imcapture.m
> which likely would have done the job as well.
>
> http://www.mathworks.com/matlabcentral/fileexchange/
> loadFile.do?objectId=13355&objectType=FILE
>
> J. Luis

Joaquim,
I think your program will help me also. Unfortunately I get
the following error when trying to run your example:

??? Error using ==> imcapture at 191
Error using ==> hardcopy
Unknown device 'none' for hardcopy.

Do you have any idea how to fix it? I am using r2007A on
windows.

Dan

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com