[R] Abline in dotplot

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed May 16 21:22:55 CEST 2007


On 5/16/07, Thompson, Valeria V <valeria.v.thompson at boeing.com> wrote:
> Hello,
>
> I have trouble adding an abline to a dotplot() from "lattice" package.
> For example, I would like to draw a line at x=3:
>
> > library(lattice)
> > x<-1:5
> > names(x) <- c("a", "b", "c", "d", "e")
> > dotplot(sample(x))
> > panel.abline(v=3)
>
> Produces a line on the left hand side of the origin. What would be a
> correct way to do this?

This would be one:

dotplot(sample(x),
        panel = function(...) {
            panel.abline(v=3)
            panel.dotplot(...)
        })

Your approach wouldn't generalize to the case where you have more than
one panel.

-Deepayan



More information about the R-help mailing list