baptiste / gridExtra

Miscellaneous Functions for "Grid" Graphics
http://cran.r-project.org/web/packages/gridExtra/index.html
15 stars 4 forks source link

Error: nrow * ncol >= n is not TRUE #17

Closed rsaporta closed 9 years ago

rsaporta commented 9 years ago

cross post with ggplot2 mailing list

I'm experiencing similar issue as to what user in the ggplot2 mailing list indicates: Old code that used to run fine now throwing error Error: nrow * ncol >= n is not TRUE

Original line of code - Throws Error

arrangeGrob(P.main, nrow=1, widths=c(10), just="bottom")
# Error: nrow * ncol >= n is not TRUE

Add ncol explicitly, throws different error

arrangeGrob(P.main, nrow=1, ncol=5, widths=c(10), just="bottom")
# Error: length(widths) == ncol is not TRUE

Change nrow from 1 to 2, and no error. But also not the output expected

arrangeGrob(P.main, nrow=2, widths=c(10), just="bottom")
# no error

Thanks

baptiste commented 9 years ago

just is not an argument of arrangeGrob, so it considers it to be a grob (which it isn't), but the number of (assumed) grobs, 2, becomes incompatible with the widths (length 1, yielding errors 1 and 2). The third case fails not because of layout incompatibility, but because just = "bottom" is not a grob.

The same issue will arise for any named argument that's not a grob, and not an argument of arrangeGrob. For instance, main is no longer an argument, it's been replaced by top for consistency with the others titles, bottom, left, right.

rsaporta commented 9 years ago

Interesting, thank you for clarifying that. Out of curiosity, why did it used to work in previous versions?

baptiste commented 9 years ago

just used to be a valid argument (although it wasn't clear from the function definition) that was passed to grid.layout. Now the layout is handled by gtable, which doesn't support justification (you'd have to wrap the grob in a gTree for that).

rsaporta commented 9 years ago

that makes sense. Do you know off the top of your head which version I could install to use the old behavior? (Have some old code I simply need to rerun with new data). If not, I could go through the commits.

thanks

baptiste commented 9 years ago

probably this one, but it may prove harder to install nowadays.

rsaporta commented 9 years ago

I'll give it a go, thanks again