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? Thank you, Valeria V. Thompson Applied Statistics Group Mathematics & Computing Technology The Boeing Company (425) 373-2740
Thompson, Valeria V said the following on 5/16/2007 12:04 PM:> 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? > > Thank you, > > Valeria V. Thompson > Applied Statistics Group > Mathematics & Computing Technology > The Boeing Company > (425) 373-2740 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.Try this instead: library(lattice) x<-1:5 names(x) <- c("a", "b", "c", "d", "e") dotplot(sample(x), panel = function(...) { panel.dotplot(...) panel.abline(v=3) }) HTH, --sundar
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
Seemingly Similar Threads
- dotplot as a background for multiple barchart plots (with Lattice)
- lattice dotplot labelling median and mean values for each panel
- how to add a vertical line for each panel in a lattice dotplot with log scale?
- [lattice] lines for stripplot (like dotplot) or jitter for dotplot?
- Lattice dotplots