[R] Set size of plot: in pdf() or par() ?

Mark Difford mark_difford at yahoo.co.uk
Wed Feb 23 15:13:02 CET 2011


On Feb 23, 2011; 03:32pm Matthieu Stigler wrote:

>>> I want to have a rectangular plot of size 0.5*0.3 inches. I am having 
>>> surprisingly a difficult time to do it...
<...snip...>
>>> If I specifz this size in pdf(), I get an error... 
>>> 
>>> pdf("try.pdf", height=0.3, width=0.5) 
>>> 
>>> par(pin=c(0.5, 0.3),mai=rep(0.1,4), omi=rep(0.01,4), mar=c(5,4,4,2)) 
>>> 
>>> plot(runif(100)) 
>>> 
>>> Error in plot.new() : figure margins too large

You are specifying the margins twice, using different units, namely mai (in
inches) and mar (in lines). The latter is throwing the error. To get what
you want, try the following:

##
pdf(paper="special", file="try.pdf", height=0.5, width=0.3) 
par(pin=c(0.5, 0.3), mai=rep(0.1,4), omi=rep(0.01,4))
plot(runif(100))
dev.off()

My PDF viewer (Adobe) tells me that the page size is 0.29 x 0.50 inch.

Regards, Mark.
> dev.off()
-- 
View this message in context: http://r.789695.n4.nabble.com/Set-size-of-plot-in-pdf-or-par-tp3319094p3321034.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list