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

Matthieu Stigler matthieu.stigler at gmail.com
Wed Feb 23 17:16:21 CET 2011


Thanks Mark!

But how does the resulting plot look like on your machine? For me, it is 
terrible... I tried then removing the mai par (to 0.01), and then got 
huge circles... It looks like there are many more parameters, I changed 
then cex, got better but still many adjustments... seems a nightmare!

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

Or am I missing one important parameter that would resize the whole thing?

I guess the best workaround is just to specify a rectangular plot 
keeping values close to the usual ones, and then resize later one, as 
suggested by David (but could not find the thread mentioned).

Thanks a lot to all of you!

Matthieu


Le 23. 02. 11 16:34, mark_difford at yahoo.co.uk a écrit :
> 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()



More information about the R-help mailing list