I am having trouble getting geom_rug to plot some data into an existing plot. Here's an example plot, where I am comparing some visit day to the magnitude of some measurement.
test <- data.frame(
visit = rep(c(0, 1.5, 3.5, 6.5, 12), 5),
mag = rnorm(n = 25)
)
ggplot(test, aes(x = visit, y = mag)) + geom_point()
Which generates the following plot.
I also have some other data, that I'd like to add just as extra marks on the x axis.
vac <- data.frame(
visit = c(2, 4, 6, 8)
)
For reasons I don't understand, I get no plot at all when I run the following code.
ggplot(test, aes(x = visit, y = mag)) + geom_point() +
geom_rug(data=vac, aes(x = visit))
I presume I have messed up on syntax somehow, but I can't seem to figure out what I am doing wrong here. Any suggestions?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…