[R] gridExtra with cairodevie and ggplots
Justin Haynes
jtor14 at gmail.com
Wed Jun 15 01:11:35 CEST 2011
Thats perfect, thank you!
On Tue, Jun 14, 2011 at 2:10 PM, baptiste auguie
<baptiste.auguie at googlemail.com> wrote:
> Hi,
>
> You can draw arrangeGrob in a rotated viewport,
>
> library(gridExtra)
> library(ggplot2)
> ps = replicate(4, qplot(rnorm(10), rnorm(10)), simplify=F)
> g = gTree(children=gList(do.call(arrangeGrob, ps)), vp=viewport(angle=90))
> grid.draw(g)
>
> though you get some warnings about clipping for some reason.
>
> Perhaps more cleanly, you can define a print.arrange method,
> (shamelessly borrowed from ggplot2),
>
> print.arrange = function (x, newpage = is.null(vp), vp = NULL, ...)
> {
> if (newpage)
> grid.newpage()
> if (is.null(vp)) {
> grid.draw(x)
> }
> else {
> if (is.character(vp))
> seekViewport(vp)
> else pushViewport(vp)
> grid.draw(x)
> upViewport()
> }
> }
>
> print(do.call(arrangeGrob, ps), vp=viewport(angle=90))
>
> HTH,
>
> baptiste
>
> On 15 June 2011 08:39, Justin Haynes <jtor14 at gmail.com> wrote:
>> I apologise in advance for not providing code, but this seems like a
>> straight forward question...
>>
>> I am making a few full page plots some of which are "portrait" and
>> some of which are "landscape"
>>
>> I would like to open my cairo device once and put all the plots in the
>> same .pdf. But since some
>> need to be rotated to fit the cairo device dimensions, is there a
>> simple parameter to arrangeGrob
>> (im using grid.arrange to generate the final plot) that will rotate
>> the entire output 90 degrees so all
>> my pages can be the same direction?
>>
>>
>> Thanks,
>> Justin
>>
>> ______________________________________________
>> R-help at 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.
>>
>
More information about the R-help
mailing list