[R] Plot Area Dimensions

2012-11-19 Thread Richard James
Dear colleagues,

I wish to create a figure with 6 plots arranged vertically with no spacing
between them as they all have a common x-axis. 

However, using the code below I'm unable to get the plot area the same size
for each plot. 

The bottom plot with the x-axis label is smaller than the others, as is the
top plot which has larger margins. 

How can I get the plot region the same size for all 6 plots, whislt still
having a large enough margin for the x-axis label on the bottom plot?

y-rnorm(1:100)
x-rnorm(1:100)
par(mfrow=c(6,1))
par(mar=c(0,5,2,5))
plot(y~x, xlab=, xaxt=n, ylab=y)
par(mar=c(0,5,0,5))
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=, xaxt=n, ylab=y)
par(mar=c(4,5,0,5))
plot(y~x, xlab=x, ylab=y)

Regards

Richard



--
View this message in context: 
http://r.789695.n4.nabble.com/Plot-Area-Dimensions-tp4650051.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] Plot Area Dimensions

2012-11-19 Thread Richard M. Heiberger
I think this task would be easier in lattice

library(lattice)
xyplot(y + y + y + y + y + y ~ x, outer=TRUE, layout=c(1,6),
  strip=FALSE, strip.left=TRUE,
  ylab=6 copies of the Y variable,
  main=put an interesting title here)

Six different y variables instead of six copies of the same would give a
more
interesting plot:

tmp - data.frame(matrix(rnorm(700), 100, 7,
  dimnames=list(1:100,
c(x,y1,y2,y3,y4,y5,y6
xyplot(y1 + y2 + y3 + y4 + y5 + y6 ~ x, data=tmp,
  outer=TRUE, layout=c(1,6),
  strip=FALSE, strip.left=TRUE,
  ylab=6 levels of the y response,
  main=put an interesting title here)


Rich

On Mon, Nov 19, 2012 at 10:51 AM, Richard James
richard.j.coo...@uea.ac.ukwrote:

 Dear colleagues,

 I wish to create a figure with 6 plots arranged vertically with no spacing
 between them as they all have a common x-axis.

 However, using the code below I'm unable to get the plot area the same size
 for each plot.

 The bottom plot with the x-axis label is smaller than the others, as is the
 top plot which has larger margins.

 How can I get the plot region the same size for all 6 plots, whislt still
 having a large enough margin for the x-axis label on the bottom plot?

 y-rnorm(1:100)
 x-rnorm(1:100)
 par(mfrow=c(6,1))
 par(mar=c(0,5,2,5))
 plot(y~x, xlab=, xaxt=n, ylab=y)
 par(mar=c(0,5,0,5))
 plot(y~x, xlab=, xaxt=n, ylab=y)
 plot(y~x, xlab=, xaxt=n, ylab=y)
 plot(y~x, xlab=, xaxt=n, ylab=y)
 plot(y~x, xlab=, xaxt=n, ylab=y)
 par(mar=c(4,5,0,5))
 plot(y~x, xlab=x, ylab=y)

 Regards

 Richard



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Plot-Area-Dimensions-tp4650051.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.


[[alternative HTML version deleted]]

__
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] Plot Area Dimensions

2012-11-19 Thread David L Carlson
You can also use layout() with base graphics. This
example sets up a column of 14 strips and allocates
3 strips to the top and bottom graphs and 2 strips
To the four middle graphs. Using Richard's tmp dataframe:

layout(matrix(c(1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
   6, 6, 6), 14, 1))
layout.show(6)
par(mar=c(0,5,2,5))
plot(y1~x, tmp, xlab=, xaxt=n, ylab=y)
par(mar=c(0,5,0,5))
plot(y2~x, tmp, xlab=, xaxt=n, ylab=y)
plot(y3~x, tmp, xlab=, xaxt=n, ylab=y)
plot(y4~x, tmp, xlab=, xaxt=n, ylab=y)
plot(y5~x, tmp, xlab=, xaxt=n, ylab=y)
par(mar=c(4,5,0,5))
plot(y6~x, tmp, xlab=x, ylab=y)

-
David L Carlson
Associate Professor of Anthropology
Texas AM University
College Station, TX 77843-4352



 -Original Message-
 From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
 project.org] On Behalf Of Richard M. Heiberger
 Sent: Monday, November 19, 2012 2:26 PM
 To: Richard James
 Cc: r-help@r-project.org
 Subject: Re: [R] Plot Area Dimensions
 
 I think this task would be easier in lattice
 
 library(lattice)
 xyplot(y + y + y + y + y + y ~ x, outer=TRUE, layout=c(1,6),
   strip=FALSE, strip.left=TRUE,
   ylab=6 copies of the Y variable,
   main=put an interesting title here)
 
 Six different y variables instead of six copies of the same would give
 a
 more
 interesting plot:
 
 tmp - data.frame(matrix(rnorm(700), 100, 7,
   dimnames=list(1:100,
 c(x,y1,y2,y3,y4,y5,y6
 xyplot(y1 + y2 + y3 + y4 + y5 + y6 ~ x, data=tmp,
   outer=TRUE, layout=c(1,6),
   strip=FALSE, strip.left=TRUE,
   ylab=6 levels of the y response,
   main=put an interesting title here)
 
 
 Rich
 
 On Mon, Nov 19, 2012 at 10:51 AM, Richard James
 richard.j.coo...@uea.ac.ukwrote:
 
  Dear colleagues,
 
  I wish to create a figure with 6 plots arranged vertically with no
 spacing
  between them as they all have a common x-axis.
 
  However, using the code below I'm unable to get the plot area the
 same size
  for each plot.
 
  The bottom plot with the x-axis label is smaller than the others, as
 is the
  top plot which has larger margins.
 
  How can I get the plot region the same size for all 6 plots, whislt
 still
  having a large enough margin for the x-axis label on the bottom plot?
 
  y-rnorm(1:100)
  x-rnorm(1:100)
  par(mfrow=c(6,1))
  par(mar=c(0,5,2,5))
  plot(y~x, xlab=, xaxt=n, ylab=y)
  par(mar=c(0,5,0,5))
  plot(y~x, xlab=, xaxt=n, ylab=y)
  plot(y~x, xlab=, xaxt=n, ylab=y)
  plot(y~x, xlab=, xaxt=n, ylab=y)
  plot(y~x, xlab=, xaxt=n, ylab=y)
  par(mar=c(4,5,0,5))
  plot(y~x, xlab=x, ylab=y)
 
  Regards
 
  Richard
 
 
 
  --
  View this message in context:
  http://r.789695.n4.nabble.com/Plot-Area-Dimensions-tp4650051.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.
 
 
   [[alternative HTML version deleted]]
 
 __
 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] Plot Area Dimensions

2012-11-19 Thread Greg Snow
The key is to not change the margins, set them once and stick with those
margins.  The next question then becomes how do I leave area at the
top/bottom for the title and common axis? to which the answer is Set
outer margins at the beginning.

Modifying your code:

y-rnorm(1:100)
x-rnorm(1:100)
par(mfrow=c(6,1), mar=c(0,5,0,5), oma=c(4,0,2,0))
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=, xaxt=n, ylab=y)
plot(y~x, xlab=x, ylab=y)


On Mon, Nov 19, 2012 at 8:51 AM, Richard James
richard.j.coo...@uea.ac.ukwrote:

 Dear colleagues,

 I wish to create a figure with 6 plots arranged vertically with no spacing
 between them as they all have a common x-axis.

 However, using the code below I'm unable to get the plot area the same size
 for each plot.

 The bottom plot with the x-axis label is smaller than the others, as is the
 top plot which has larger margins.

 How can I get the plot region the same size for all 6 plots, whislt still
 having a large enough margin for the x-axis label on the bottom plot?

 y-rnorm(1:100)
 x-rnorm(1:100)
 par(mfrow=c(6,1))
 par(mar=c(0,5,2,5))
 plot(y~x, xlab=, xaxt=n, ylab=y)
 par(mar=c(0,5,0,5))
 plot(y~x, xlab=, xaxt=n, ylab=y)
 plot(y~x, xlab=, xaxt=n, ylab=y)
 plot(y~x, xlab=, xaxt=n, ylab=y)
 plot(y~x, xlab=, xaxt=n, ylab=y)
 par(mar=c(4,5,0,5))
 plot(y~x, xlab=x, ylab=y)

 Regards

 Richard



 --
 View this message in context:
 http://r.789695.n4.nabble.com/Plot-Area-Dimensions-tp4650051.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.




-- 
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

[[alternative HTML version deleted]]

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