Skip to content
Prev 317340 / 398506 Next

how to make a median line thicker in bwplot (lattice)

Hi

I had a similar problem - see

http://tolstoy.newcastle.edu.au/R/e9/help/10/03/7129.html

DF <-
data.frame(site = factor(rep(1:5, each = 20)),
            height = rnorm(100))

   bwplot(height~ site,DF,
          pch   = "|",
          panel = function(x, y, ..., horizontal) {

                     panel.bwplot(x, y, ...,  horizontal = horizontal)

                     if (horizontal) {

                       meds <- tapply(x, y,  median)
                       ylocs <- seq_along(meds)
                       panel.segments(meds, ylocs - 1/4,
                                      meds, ylocs + 1/4,
                                      lwd = 2, col = "red")

                     } else {

                       meds <- tapply(y, x, median)
                       xlocs <- seq_along(meds)
                       panel.segments(xlocs - 1/4, meds,
                                      xlocs + 1/4, meds,
                                      lwd = 2, col = "red")

                    } ## if (horizontal)
                  }  ## panel function
   ) ## bwplot

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
At 01:35 12/02/2013, you wrote: