Skip to content
Prev 334231 / 398503 Next

lattice: superposed boxplots with same colors forrectanglesandumbrellas and filled boxes

Thank you very much, Rich, for the fast and very helpful reply! It helped 
me to reach my goal.

  Regards -- Gerrit

PS: I extended your solution to a version that allows slightly finer 
control over the components of the boxplots, in particular if one wants to 
combine it with, e.g., panel.stripplot() or panel.average(). It was also 
possible to simplify my call of bwplot() a bit. The code is certainly not 
perfect and fully tested, but does work (for me ;-)), and follows as a 
little 'thank you':


panel.bwplot.constantColor <- function( ..., col, fill, cex, pch,
                                         dot.pch, umbrella.lty, box.alpha) {
  ## Date: Mon, 9 Dec 2013 17:52:38 -0500
  ## From: Richard M. Heiberger <rmh at temple.edu>
  ## Subject: Re: [R] lattice: superposed boxplots with same colors
  ##          for rectangles and umbrellas and filled boxes

  ## to be included in next version of the HH package
  box.save <- list( box.dot = trellis.par.get( "box.dot"),
                    box.rectangle = trellis.par.get( "box.rectangle"),
                    box.umbrella = trellis.par.get( "box.umbrella"),
                    plot.symbol = trellis.par.get( "plot.symbol"))
  trellis.par.set( box.dot = list( col = col),
                   box.rectangle = list( col = col, alpha = box.alpha),
                   box.umbrella = list( col = col, lty = umbrella.lty,
                                        alpha = box.alpha),
                   plot.symbol = list( col = col))
  panel.bwplot( ..., fill = col, cex = cex, pch = dot.pch)
  trellis.par.set( box.save)
  }


bwplot( Y ~ F1, groups = F2, data = Data, jitter.data = TRUE,
         col = c( "red", "blue"), box.alpha = 1/4,
         dot.pch = 17, umbrella.lty = 1, do.out = FALSE,
         panel = panel.superpose,
         panel.groups = panel.bwplot.constantColor)