С базовой графикой в пакете есть функция draw.circle
plotrix
.
Сначала я переделаю график в вопросе.
library(plotrix)
set.seed(1234) # Make the results reproducible
a <- runif(1000, 1, 100)
b <- runif(1000, 30, 200)
c <- runif(1000, 45, 160)
plot(sort(a),sort(b), xlab = "fraction of population a", ylab = "something happening to population a")
points(sort(a), sort(c), col="red")
legend("topleft", legend = c("time 0", "time 1"), pch=1, lwd=2.5, col = c("black","red"))
Теперь круги.
draw.circle(x = 80, y = 50, radius = 12, border = "black")
draw.circle(x = 80, y = 46, radius = 9, border = "red")
И, наконец, этикетки. Поскольку есть числа, я вычислил предсказанные значения оси y
для x = 100
, учитывая линейную модель.
fit_1 <- lm(sort(b)~sort(a))
fit_0 <- lm(sort(c)~sort(a))
t1 <- predict(fit_1, newdata = data.frame(a = 100))
t0 <- predict(fit_0, newdata = data.frame(a = 100))
t1 <- round(t1)
t0 <- round(t0)
text(80, 65, labels = t1, pos = 3, cex = 0.65)
text(80, 56, labels = t0, pos = 3, cex = 0.65)
text(80, 75, labels = "Population", pos = 3) # Plot once
text(80, 75, labels = "Population", pos = 3) # Overplot to make it darker