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

2011-02-23 Thread Matthieu Stigler

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.


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

2011-02-23 Thread Ista Zahn
It should be specified in pdf() as you did. If you try

pdf(try.pdf, height=2, width=2)

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

I think the problem will become apparent.

best,
Ista

On Wed, Feb 23, 2011 at 12:39 PM, Matthieu Stigler
matthieu.stig...@gmail.com 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.




-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

__
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.


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

2011-02-23 Thread Matthieu Stigler

Dear Ista

Thanks a  lot for your help! However, when I spedify the right size I 
wish (the same as specified in par() ) I get an error:


pdf(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), mar=c(5,4,4,2))

plot(runif(100))

dev.off()


I don't see why my marings now would have become too small ... any idea?

Thanks!!


Le 23. 02. 11 14:22, Ista Zahn a écrit :

It should be specified in pdf() as you did. If you try

pdf(try.pdf, height=2, width=2)

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

I think the problem will become apparent.

best,
Ista

On Wed, Feb 23, 2011 at 12:39 PM, Matthieu Stigler
matthieu.stig...@gmail.com  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.


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

2011-02-23 Thread David Winsemius


On Feb 23, 2011, at 8:32 AM, Matthieu Stigler wrote:


Dear Ista

Thanks a  lot for your help! However, when I spedify the right size  
I wish (the same as specified in par() ) I get an error:


pdf(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), mar=c(5,4,4,2))


Given the size of the margins (determined by fonts and line width  
defaults) the smallest (but still useless) pdf I can create is:


 pdf(try.pdf, height=2.2, width=1.4)
 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()
quartz
 2

You should rethink your strategy and articulate your goals and  
constraints a bit better. I remember a discussion in rhelp of setting  
sizes for graphical files within the last week where the consensus of  
knowledgeable useRs was to make a bigger file and then resize it.


--
David.




plot(runif(100))

dev.off()


I don't see why my marings now would have become too small ... any  
idea?


Thanks!!


Le 23. 02. 11 14:22, Ista Zahn a écrit :

It should be specified in pdf() as you did. If you try

pdf(try.pdf, height=2, width=2)

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

I think the problem will become apparent.

best,
Ista

On Wed, Feb 23, 2011 at 12:39 PM, Matthieu Stigler
matthieu.stig...@gmail.com  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.


David Winsemius, MD
West Hartford, CT

__
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.


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

2011-02-23 Thread Mark Difford

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.

__
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.


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

2011-02-23 Thread Matthieu Stigler

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_diff...@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()


__
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.


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

2011-02-23 Thread Peter Ehlers

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.