Skip to content

put strip below the panel (dotplot)

2 messages · Elaine Kuo, Peter Ehlers

#
On 2013-02-28 04:20, Elaine Kuo wrote:
I don't think that this is trivial. I would just use panel.text() and
panel.rect() to create my own strips. [I do wonder why you would want
to have the strips at the bottom - seems unnatural to me.]

Here's a start, using the iris data:

   dotplot(Sepal.Length ~ Petal.Length | Species, data=iris,
      layout = c(3, 1),
      ylim = c(-2, 37),    ## adjust y-range to leave a bit
                           ##  of space at bottom
      strip = FALSE,       ## omit top strips
      panel = function(...){
        cp <- current.panel.limits()
        stripheight <- (cp$ylim[2] - cp$ylim[1]) / 25
                           ## may have to adjust the '25'
        xleft <- cp$xlim[1]
        xright <- cp$xlim[2]
        ybottom <- cp$ylim[1]
        ytop <- cp$ylim[1] + stripheight
        lab <- levels(iris$Species)[panel.number()]
        panel.dotplot(...)
        panel.rect(xleft, ybottom, xright, ytop, fill = "bisque")
        panel.text(x = (xleft + xright) / 2,
                   y = (ybottom + ytop) / 2,
                   labels = lab)
      })


Peter Ehlers