Skip to content

Help combining cell labelling and multiple mosaic plots

1 message · Paul Murrell

#
Hi

The problem is that BOTH mosaic() and labeling_cells() are calling 
seekViewport() to find the right viewport to draw into and for BOTH 
plots they are finding the same viewports (on the left side of the 
page).  The following code solves the problem (for me anyway) by 
specifying a different 'prefix' for each mosaic() and labeling_cells() 
call ...


grid.newpage()
pushViewport(viewport(layout=grid.layout(1,2)))
pushViewport(viewport(layout.pos.col=1))
mosaic(.test, gp=shading_hsv, pop=FALSE, split_verticaL=FALSE,
        newpage=FALSE,
        labeling_args=list(offset_varnames=c(top=3),
                           offset_labels=c(top=2)),
        prefix="plot1")
labeling_cells(text=round(prop.table(.test, 1), 2)*100,
                clip=FALSE)(.test, prefix="plot1")
upViewport()

pushViewport(viewport(layout.pos.col=2))
mosaic(.test1, gp=shading_hsv, newpage=FALSE, pop=FALSE,
        split_vertical=FALSE,
        labeling_args=list(offset_varnames=c(top=3),
                           offset_labels=c(top=2)),
        prefix="plot2")
labeling_cells(text=round(prop.table(.test1, 1), 2)*100,
                clip=FALSE)(.test1, prefix="plot2")
popViewport(2)


... hope that helps.

Paul
On 1/11/2011 5:21 a.m., Simon Kiss wrote: