[R] passing par() options to pdf under Sweave

Friedrich.Leisch@ci.tuwien.ac.at Friedrich.Leisch at ci.tuwien.ac.at
Fri Dec 5 08:15:22 CET 2003


>>>>> On Thu, 4 Dec 2003 15:58:32 -0800 (PST),
>>>>> Anne York (AY) wrote:

  > I'm using Sweave to generate LaTeX output from R. Thank-you 
  > very much for this capability. It is very useful.

  > Could someone please tell me how to pass non-default 
  > graphics parameters from par() to the pdf driver when it is 
  > called by Sweave? 

  > (I need to change some of the margin defaults. )

  > Hoping there is an easy solution to this question,

Yes, simply define a hook function for figure chunks: The effect of

options(SweaveHooks=list(fig=function() par(bg="red", fg="blue")))


should be easy to see :-) The hook function will be executed at the
beginning of each chunk where fig=true (i.e., all figure chunks).


What you want is something like

options(SweaveHooks=list(fig=function() par(mar=c(1,2,3,4))))


Hope this helps,

-- 
-------------------------------------------------------------------
                        Friedrich  Leisch 
Institut für Statistik                     Tel: (+43 1) 58801 10715
Technische Universität Wien                Fax: (+43 1) 58801 10798
Wiedner Hauptstraße 8-10/1071      Friedrich.Leisch at ci.tuwien.ac.at
A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch




More information about the R-help mailing list