Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. x <- replicate(8, arima.sim(list(ar = 0.1, ma = 2.5), 4))
  2. preylabs <- paste("Prey", 1:4) # for plotting
  3.  
  4. ## the ugly way ----
  5. library(compactr) # a very nice convenience package for ploting
  6. eplot(xlim = c(1, 4), ylim = c(-9, 10),
  7. xat = 1:4, xticklab = preylabs,
  8. ylab = "Time", main = "Ugly")
  9. invisible(apply(x, 2, function(xj) {
  10. points(xj, pch = 16)
  11. lines(xj)
  12. }))
  13.  
  14. ## checkerboard ----
  15.  
  16. checkercols <- colorRamp(c("white", "black"))((1:20)/20) / 255
  17. checkercols <- apply(checkercols, 1, function (x) rgb(x[1], x[2], x[3]))
  18.  
  19. image(x, col = checkercols, xaxt = "n", yaxt = "n")
  20. axis(1, at = (0:3) / 3, labels = preylabs)
  21. axis(2, at = (0:7) / 7, labels = 1:8)
  22. mtext("Individual", 2, line = 2)
  23. title(main = "I like these", outer = TRUE, line = -1.5)
  24.  
  25. ## small multiples ----
  26.  
  27. op <- par
  28. par(mfrow = c(2, 4),
  29. mar = rep(0.75, 4),
  30. oma = c(2.5, 2.5, 3, 1))
  31. invisible(apply(x, 2, function (xj) {
  32. eplot(xlim = c(1, 4), ylim = c(-9, 10), xat = 1:4)
  33. points(xj, pch = 16)
  34. lines(xj)
  35. }))
  36. title(main = "These can be good, too", outer = TRUE, cex.main = 1.5)
  37. mtext("Time", 2, line = 1, outer = TRUE)
  38. mtext("Prey", 1, line = 1, outer = TRUE)
  39. par(op)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement