Advertisement
jmbm

Fig_12

Jul 26th, 2023
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.46 KB | None | 0 0
  1. #---- Huffaker 2 naranjas
  2. # fig_12
  3.  
  4. # variables
  5. N1 <- numeric()  # naranja 1
  6. P1 <- numeric()
  7. N2 <- numeric()  # naranja 2
  8. P2 <- numeric()
  9.  
  10. # coeficientes
  11. lambda <- 1.4    # tasa crecimiento
  12. c <- 3           # huevos parásito
  13. a <- 0.01         # eficacia parásito
  14. m <- 0.05         # fracción emigrante
  15.  
  16. # condiciones simulación
  17. ngen <- 2000      # generaciones
  18. N1[1] <- 30      # N inicial
  19. N2[1] <- 0
  20. P1[1] <- 50      # P inicial
  21. P2[1] <- 0
  22.  
  23. # simulación
  24. for (t in 1:ngen) {
  25.   # en la naranja 1
  26.   f1 <- exp(-a * P1[t])
  27.   N1[t + 1] <- lambda * N1[t] * f1 * (1 - m) + m*N2[t]
  28.   P1[t + 1] <- lambda * c * N1[t] * (1 - f1) * (1 - m) - m*(P1[t] - P2[t])
  29.   # en la naranja 2
  30.   f2 <- exp(-a * P2[t])
  31.   N2[t + 1] <- lambda * N2[t] * f2 * (1 - m) + m*N1[t]
  32.   P2[t + 1] <- lambda * c * N2[t] * (1 - f2) * (1 - m) - m*(P2[t] - P1[t])
  33. }
  34.  
  35. # gráfico (dos en la misma figura)
  36. pdf("fig_12.pdf", width = 7, height = 6)
  37. par(pty = "s",
  38.     bty = "n",
  39.     mar = c(5, 2, 1, 1),
  40.     xaxs = "i",
  41.     yaxs = "i",
  42.     las = 1)
  43. plot(N1, P1,
  44.     type = "b",
  45.     lty = 1,
  46.     cex = 0.8,
  47.     pch = 16,
  48.     col = "royalblue",
  49.     xlim = c(0, 120),
  50.     ylim = c(0, 300),
  51.     xlab = "N",
  52.     ylab = "P")
  53. lines(N2, P2,
  54.     type = "b",
  55.     lty = 2,
  56.     cex = 0.8,
  57.     pch = 21,
  58.     col = "coral")
  59. legend("topright",
  60.     c("naranja 1", "naranja 2"),
  61.     lty = c(1, 2),
  62.     cex = 1,
  63.     pch = c(16, 21),
  64.     col = c("royalblue", "coral"),
  65.     bty = "n")
  66. dev.off()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement