The problem with your code is that you are passing widths to the matrix
function instead of the layout function.  The matrix function does not
know what you want to do with the "widths" and gives the error.  Move
that section to between the last 2 parentheses:

> layout( matrix( 1:9, ncol=3, byrow=TRUE), widths=c(2,1,1) )

A possibly better approach would be to create an outer margin on the
left side and reduce the margins inside:

> par(oma=c(0,4,0,0), mar=rep(.1,4))

Then plot without the automatic axes and use the axis function with
outer=TRUE to place the axis.  Maybe something like:

> par( mfrow=c(3,3), oma=c(4,4,0,0)+.1, mar=rep(.1,4) )
> 
> for(i in 1:9) {
+ plot( rnorm(10*i), rnorm(10*i), ann=FALSE, axes=FALSE, 
+ xlim=c(-3,3), ylim=c(-3,3) )
+ box()
+ if( i %% 3 == 1 ) axis(2, outer=TRUE)
+ if( i %/% 3 == 1 ) axis(1, outer=TRUE)
+ }


Hope this helps,


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Peter H Singleton
> Sent: Wednesday, March 12, 2008 1:51 PM
> To: r-help@r-project.org
> Subject: [R] Problem with specifiying column widths in layout
> 
> 
> I am trying to generate a graphic with a matrix of 9 line 
> graphs (3 rows, 3 columns), all with the same y-axis range, 
> and only showing the y-axis labels and title at the left edge 
> of each row of the matrix. I have been trying to use the 
> widths argument in layout to specify a larger column width in 
> the left column so that I have room for the y-axis labels and 
> title, but I get the following error:
> 
> > layout(matrix(1:9, ncol=3, widths=c(2,1,1), byrow=TRUE))
> 
> Error in matrix(1:9, ncol = 3, widths = c(2, 1, 1), byrow = TRUE) :
>   unused argument(s) (widths = c(2, 1, 1))
> 
> I think I'm correctly following the example on p80 in 
> Murrell, and I've seen other people using this syntax in 
> listserv posts, but I'm obviously doing something wrong. Any 
> suggestions?
> 
> <<->><<->><<->><<->><<->><<->><<->>
> Peter Singleton
> USFS Pacific Northwest Research Station
> 
> ______________________________________________
> 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