I am trying to replicate this plot in R.
I have some difficulties: I don't know the code to create the line 90 min (it is not a continuous line, it starts at 2000)
How can I add the text R1, R2 and R3 in my plot?
How can I add the title for each line in my plot?
This is my current code:
plot(Year,Duration, abline(v=2000, col="green"))
Thanks
Here's a stab at it, base graphics.
set.seed(42)
dat <- data.frame(
Year = sample(1990:2040, size=100, replace=TRUE),
Duration = runif(n=100, min=-1, max=1)
)
plot(Duration ~ Year, data = dat, pch = 16, yaxt = 'n', xaxt = 'n', col = "orange")
abline(v = 2000, lwd = 2, col = "green4")
lines(c(2000, par("usr")[2]), rep(0, 2), lwd = 2, col = "green4")
text(c(1995, 2025, 2025), c(0, -0.5, 0.5), c("R1", "R2", "R3"))
mtext("90min", side = 4)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.