[R] multiple mosaic plots layout

Achim Zeileis Achim.Zeileis at uibk.ac.at
Mon May 2 09:23:32 CEST 2011


On Mon, 2 May 2011, baptiste auguie wrote:

> Unfortunately, it seems that vcd doesn't return grobs but draws
> directly to the device, which prevents a concise solution.

Yes. The reason is that vcd was first written before grobs were available.

When we need multiple plots in a single layout, we use Baptiste's second 
(more verbose) solution. A worked example is included in ?Ord_plot.

> You could try the following,
>
> library(gridExtra)
> library(vcd)
> data("Titanic")
>
> p = grid.grabExpr(mosaic(Titanic))
> grid.arrange(p, p, p, ncol=2)
>
> Or, more versatile but also more verbose,
>
> pushViewport(...)
> mosaic(...)
> upViewport()
> pushViewport(...)
> mosaic(...)
> upViewport()
> etc..
>
> HTH,
>
> baptiste
>
> On 2 May 2011 11:32, Neuwirth Erich <erich.neuwirth at univie.ac.at> wrote:
>> I would like to display multiple mosaic plots from vcd (not defined by a model but derived from different data sets)
>> side by side.
>> Neither par(mfrow=...)
>> nor layout seem to allow to arrange multiple mosaic plots in a grid.
>> Is there an easy way of arranging mosaics in a grid?
>>
>> ______________________________________________
>> 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.
>>
>
> ______________________________________________
> 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