0

I am trying to replicate this plot in R.

enter image description here

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

Zach
  • 29
  • 1
  • 4
  • can you provide the code you have tried so far ? and the dataset you are using ? You can check on this link to know how to provide [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – dc37 Nov 20 '19 at 05:22

1 Answers1

2

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)

sample graphic

r2evans
  • 141,215
  • 6
  • 77
  • 149