Matthieu,

A couple of points that you may be misunderstanding:

1.
your 'mar' setting overwrites the 'mai' setting;
use one or the other.

2.
pdf(width=0.5, height=0.3) sets the *device* region
dimensions, not the *plot* region. The thing to
remember is that "device contains figure contains plot".
[check par()$din, par()$fin, par()$pin]

You're fitting a plot plus margins plus outer margins
into a device; unless all margins are zero, the plot
will have to be smaller than the device region.

Note also that your 'mai' setting interacts with
the 'pin' setting. Try this on your monitor:

 par(mai = rep(.1,4), pin = c(0.5, 0.3))
 plot(1:10)
 dev.off()

 par(pin = c(0.5, 0.3), mai = rep(.1,4))
 plot(1:10)
 dev.off()

There's a note on the ?par page:
  "In particular, the settings of mai, mar, pin, plt
   and pty interact, ..."

Peter Ehlers

On 2011-02-23 04:39, Matthieu Stigler wrote:
Dear R List

Could I ask again my question about where the size of a plot should be
specified (in par or pdf?). I still did not figure out, and any help
would be much appreciated!!

Thanks a lot!

Matthieu

Le 22. 02. 11 13:53, Matthieu Stigler a écrit :
Hi

I want to have a rectangular plot of size 0.5*0.3 inches. I am having
surprisingly a difficult time to do it... Since I will export it, I
use also pdf(). The plot works fine, but once I specify the size in
pdf() I get problems... see:

Say I specify my plot as following:

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))


If I now add

pdf()

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))

dev.off()


The resulting pdf has not the size specified!

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


So obviously pdf() is modifying some other par() parameter I could not
figure out... Any idea?

Thanks!!

Matthieu

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to