Advertisement
jmbm

Fig_03

Jul 13th, 2023
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.37 KB | None | 0 0
  1. #---- Nicholson & Bailey
  2. # fig_03
  3.  
  4. # variables
  5. N <- numeric()
  6. P <- numeric()
  7.  
  8. # coeficientes
  9. lambda <- 1.5
  10. c <- 3
  11. a <- 0.1
  12.  
  13. # condiciones simulación
  14. ngen <- 30     # generaciones
  15. N[1] <- 3      # N inicial
  16. P[1] <- 4      # P inicial
  17.  
  18. # simulación
  19. for (t in 1:ngen) {
  20.   f <- exp(-a * P[t])
  21.   N[t + 1] <- lambda * N[t] * f
  22.   P[t + 1] <- lambda * c * N[t] * (1 - f)
  23. }
  24.  
  25. # equilibrio
  26. Peq <- log(lambda) / a
  27. Neq <- Peq / (c * (lambda - 1))
  28.  
  29. # gráfico (dos en la misma figura)
  30. pdf("fig_03.pdf", width = 5, height = 9)
  31. colorN <- "olivedrab"
  32. colorP <- "coral"
  33. par(mfrow = c(2, 1),
  34.     pty = "s",
  35.     bty = "n",
  36.     mar = c(5, 2, 1, 1),
  37.     xaxs = "i",
  38.     yaxs = "i",
  39.     las = 1)
  40. plot(0:ngen, N,
  41.     type = "b",
  42.     col = colorN,
  43.     cex = 0.7,
  44.     pch = 16,
  45.     ylim = c(0, 20),
  46.     ylab = "N, P",
  47.     xlab = "Generación")
  48. lines(0:ngen, P,
  49.     type = "b",
  50.     col = colorP,
  51.     cex = 0.6,
  52.     pch = 21)
  53. legend("topleft",
  54.     bty = "n",
  55.     c("hospedador (N)", "parásito (P)"),
  56.     col = c(colorN, colorP),
  57.     lty = 1,
  58.     pch = c(19, 21),
  59.     cex = 0.8,
  60.     pt.bg = "white")
  61. plot(N, P,
  62.     type = "b",
  63.     lty = 2,
  64.     cex = 0.8,
  65.     pch = 16,
  66.     col = "royalblue",
  67.     xlim = c(0, 10),
  68.     ylim = c(0, 20))
  69. abline(h = Peq,
  70.     col = "orange",
  71.     lwd = 0.5)
  72. abline(v = Neq,
  73.     col = "orange",
  74.     lwd = 0.5)
  75. dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement