Skip to content
Prev 243875 / 398506 Next

Passing par()-parameters to many plot()s in a function

On 03/12/2010 12:22 PM, Alexx Hardt wrote:
Generally speaking par() affects the current graphics device.  Your code 
below only opens one graphics device,
so it should be fine to call par() once. (But you did forget to call 
dev.off(), so you will probably run into problems on the last plot.)

Another way to do this is to call pdf() and dev.off() 10 times.  The 
pdf.options() function sets defaults for a number of things related to a 
new pdf() device, but par() options are not included, so you'd need to 
call it before each plot.

There are surely some par() options that are cleared as you move to a 
new plot in your onefile=FALSE usage; I don't think the margin 
parameters are among them, but you might find it easiest just to set 
everything each time even if you are using only one pdf() device.

Duncan Murdoch