In below graph, I would like to add two vertical lines using
panel.abline().  Is this possible?

Thanks,
Naresh

mydf <- data.frame(hour = rep(6:20, 2),
traffic = c(round(dnorm(6:20, 9, 3) * 10000), round(dnorm(6:20, 17, 4) *
10000)),
direction = rep(c("inbound", "outbound"), c(15, 15)))

vehicles <- data.frame(hour = 6:20,
count = c(100, 120, 140, 125, 105, 80, 70, 75, 80, 100, 110, 120, 115,
110, 100))

library(lattice)
library(latticeExtra)

# This works
mybars <- barchart(traffic ~ as.factor(hour), groups = direction,
stack = TRUE, horizontal = FALSE, data = mydf,
auto.key = list(columns = 2, space = "bottom"), xlab = "hour")

mylines <- xyplot(count ~ as.factor(hour), type = "l", lwd = 2,
col = 2, data = vehicles)

mybars + mylines

# This does not work.  Lines are not correctly placed.
mylines <- xyplot(count ~ as.factor(hour), type = "l", lwd = 2,
col = 2, data = vehicles, panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
panel.abliine(v = as.factor(c(9, 17)), lty = 2, col = "gray")
})
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to