[R] getting cd_plot in vcd package to work with layout

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Jun 19 18:44:54 CEST 2009



Lyndon Walker wrote:
> Hi,
> I'm trying to get 2x2 (or other layouts) of cd_plot from the vcd package.  I
> have tried the usual commands like layout, par(mfrow...) etc and but cd_plot
> seems to ignore them and send the plotting window back to 1x1.  I have also
> tried turning off the pop and newpage options in cd_plot but I still can't
> get multiple cd_plots into a plotting window.
> 
> Any suggestions would be greatly appreciated.

This is because cd_plot() uses the grid framework rather than the R base 
graphics system. Hence use it inside a grid viewport.

Example:

library("vcd")
pushViewport(vp <- viewport(x = 0.25, y = 0.5,
                w = 0.5, h = 1))
cd_plot(Improved ~ Age, data = Arthritis, newpage=FALSE)
popViewport()
pushViewport(vp <- viewport(x = 0.75, y = 0.5,
                w = 0.5, h = 1))
cd_plot(Improved ~ Age, data = Arthritis, newpage=FALSE)
popViewport()

Uwe Ligges





> cheers
> Lyndon
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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