Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: problems printing to file
Date: Sun, 12 Apr 2009 19:56:01 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 46
Message-ID: <grth0h$ccv$1@fred.mathworks.com>
References: <49e1f8e8@news.mel.dft.com.au>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1239566161 12703 172.30.248.37 (12 Apr 2009 19:56:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 12 Apr 2009 19:56:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869871
Xref: news.mathworks.com comp.soft-sys.matlab:532187


Ross <ross@nospam.com> wrote in message <49e1f8e8@news.mel.dft.com.au>...
> Dear folks
> 
> What I want to do is very straighforward - to transfer the plotted screen 
> figures exactly as they appear on the screen to graphics files with the same 
> pixel dimensions and the same colour depth as the screen figure, under program 
> control.  Lossless compression is desirable, but not obligatory.
> 
> In R2008b,  using the PRINT command, the -dbitmap driver is the only one that 
> creates the correct sized file image, but it is not acceptable for shaded 
> figures because it cuts the colour depth from 24bit to 8bit.
> The -dbmp, -dpng and -dtiff drivers retain 24bit colour but are completely 
> useless because they save only a fraction of the screen figure (a rectangle 
> based on the lower lefthand corner), and the size of this portion is not 
> altered by any of the dpi settings.
> Fiddling with all the options that are allowable in the PRINT command doesn't 
> seem to fix any of these problems.
> 
> Interactive saving to file via the Figure menu bar DOES work.  Furthermore, if 
> I change the File / Export Setup / Rendering / Resolution setting from 'auto' 
> to 'screen', then further exporting of the same figure in m-code (PRINT 
> command) now works correctly.  It continues to work correctly even if the 
> setting is changed back to 'auto' !  However this is specific to each figure, 
> and means that prior manual intervention is necessary for every figure.  I 
> couldn't find any option for the PRINT command or in the various startup files 
> that has the same effect.  The '-r0' option certainly doesn't.
> 
> My programs usually generate multiple plots, from 5 to 30 at a time, so I need 
> the figures to be saved under program control.  I don't see everyone else 
> complaining about this:  so if it's something I'm doing wrong,  what the hell 
> is it?
> Is there a command which can be used in m-files which has the same effect as 
> setting Resolution to 'screen' in the Export Setup?
> 
> Thanks
> Ross

Ross,

To programmatically set the plot to save as you see on the screen, set the PaperPositionMode of the figure to "auto".

>> surf(peaks)
>> set(gcf,'PaperPositionMode','auto')
>> print -dpng -r0 peaks.png

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/figure_props.html#PaperPositionMode