Skip to content
Prev 256196 / 398506 Next

dotplot as a background for multiple barchart plots (with Lattice)

On Thu, Apr 7, 2011 at 7:16 PM, Christian Charles
<christian.charles at inrialpes.fr> wrote:
Here is a literal solution (plot the 'meanplot' object in each panel):

barchart(MeanX + MeanZ ~ Type|Subject,
         data=test ,
         scales = list(x = list(rot = 60)),
         layout=c(1, l),
         panel = function(...) {
             plot(meanplot, newpage = FALSE)
             panel.abline(h=0)
             panel.grid(v = -length(levels(factor(test$Type))), h=0)
             panel.barchart(...)
         })

but a better solution may be to draw just the panel part (which
doesn't work very well because the y-limits are different).

barchart(MeanX + MeanZ ~ Type | Subject,
         data=test ,
         scales = list(x = list(rot = 60)),
         layout=c(1, l),
         panel = function(...) {
             mpargs <- trellis.panelArgs(meanplot, 1)
             do.call(meanplot$panel, mpargs)
             panel.abline(h=0)
             panel.grid(v = -length(levels(factor(test$Type))), h=0)
             panel.barchart(...)
         })

-Deepayan