Guest User

Untitled

a guest
Jul 15th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. ## setwd('path/to/magnificent/images/noimage')
  2. set.seed(123)
  3. png("thumbnail%d.png", width = 73, height = 73)
  4. par(mar = rep(0, 4), ann = FALSE, xaxt = "n", yaxt = "n")
  5.  
  6. hist(rnorm(100), main = "", col = heat.colors(8))
  7.  
  8. boxplot(list(rnorm(100), runif(100)), col = 2:3)
  9.  
  10. sunflowerplot(iris[, 1:2], pch = 20, col = "gold", size = 1/20)
  11. lines(lowess(iris[, 1], iris[, 2]), lwd = 2, col = rgb(0, 1, 0, 0.5))
  12.  
  13. smoothScatter(iris[, 1:2])
  14.  
  15. contour(volcano, nlevels = 6, drawlabels = FALSE)
  16.  
  17. fourfoldplot(margin.table(aperm(UCBAdmissions, c(2, 1, 3)), c(1, 2)))
  18.  
  19. image(t(volcano)[ncol(volcano):1, ])
  20.  
  21. mosaicplot(~gear + carb, data = mtcars, color = TRUE, las = 1, main = "",
  22. xlab = "", ylab = "")
  23.  
  24. z <- 4 * volcano
  25. x <- 10 * (1:nrow(z))
  26. y <- 10 * (1:ncol(z))
  27. persp(x, y, z, theta = 135, phi = 30, col = "green3", scale = FALSE, ltheta = -120,
  28. shade = 0.75, border = NA, box = FALSE)
  29.  
  30. stars(mtcars[1:9, 1:7], labels = NULL, col.stars = terrain.colors(9))
  31.  
  32. ## 波波头一头
  33. library(sna)
  34. gplot(rgraph(10, tprob = runif(10, 0.1, 0.3)), vertex.sides = 4, vertex.lty = 0,
  35. vertex.cex = runif(10, 5, 10), usearrows = F, edge.col = grey(runif(10, 0.6,
  36. 0.8)), vertex.col = sample(rainbow(10), re = T))
  37. text(2.2, 2.4, "bo", cex = 0.7)
  38.  
  39. ## 王晓伟
  40. r <- runif(1, 0.25, 0.75)
  41. d <- runif(1, 0.25 * r, r)
  42. t <- 2 * pi * seq(0, 10, by = 0.1)
  43. x <- (1 - r) * cos(t) + d * cos((1 - r) * t/r)
  44. y <- (1 - r) * sin(t) - d * sin((1 - r) * t/r)
  45. plot(x, y, type = "l", col = "blue", lwd = 0.5)
  46. text(-0.8, 0.8, "w", cex = 0.7)
  47.  
  48. ## 主伟呈
  49. x = rnorm(100)
  50. y = x^2 + runif(100, 0, 3)
  51. zones = matrix(c(2, 0, 1, 3), ncol = 2, byrow = T)
  52. layout(zones, widths = c(2/3, 1/3), heights = c(1/3, 2/3))
  53. xhist = hist(x, plot = F)
  54. yhist = hist(y, plot = F)
  55. top = max(c(xhist$counts, yhist$counts))
  56. par(mar = c(0.2, 0.2, 0, 0))
  57. plot(x, y, xlim = c(min(x), max(x)), ylim = c(min(y), max(y)), pch = 20,
  58. col = "grey70")
  59. text(mean(x), quantile(y, prob = 0.98), "z", cex = 0.7)
  60. lines(lowess(x, y), col = "grey40")
  61. par(mar = c(0, 0.2, 0, 0))
  62. barplot(xhist$counts, axes = F, ylim = c(0, top), space = 0, col = "green")
  63. par(mar = c(0.2, 0, 0, 0))
  64. barplot(yhist$counts, axes = F, xlim = c(0, top), space = 0, horiz = T,
  65. col = "yellow")
  66. layout(1)
  67.  
  68. ## 邱怡轩
  69. par(mar = rep(0, 4), ann = FALSE, xaxt = "n", yaxt = "n")
  70. pie(c(1, 1, 2, 3, 3), labels = "", col = rainbow(5), radius = 1, border = "white")
  71. theta = 0.1 * pi
  72. text(0.75 * cos(theta), 0.75 * sin(theta), "A", col = "white")
  73. theta = 0.3 * pi
  74. text(0.75 * cos(theta), 0.75 * sin(theta), "C", col = "white")
  75. theta = 0.6 * pi
  76. text(0.75 * cos(theta), 0.75 * sin(theta), "I", col = "white")
  77. theta = 1.1 * pi
  78. text(0.75 * cos(theta), 0.75 * sin(theta), "S", col = "white")
  79. theta = 1.7 * pi
  80. text(0.75 * cos(theta), 0.75 * sin(theta), "T", col = "white")
  81. text(0.9, 0.9, "q", cex = 0.7)
  82.  
  83. ## cogitovita
  84. rot = function(x, y, theta) {
  85. x1 = sin(theta) * x + cos(theta) * y
  86. y1 = -cos(theta) * x + sin(theta) * y
  87. list(x = x1, y = y1)
  88. }
  89. x = runif(1000, -7, 7)
  90. y = x + runif(1, 3, 5)
  91. plot(x, y, xlim = c(-14, 14), ylim = c(-14, 14), type = "n")
  92. n = 99
  93. # copy color function from Xie Laoda!
  94. color = apply(replicate(2 * n, sample(c(0:9, LETTERS[1:6]), 8, replace = TRUE)),
  95. 2, function(x) sprintf("#%s", paste(x, collapse = "")))
  96. for (i in 1:n) {
  97. points(rot(x, y, runif(1, -pi, pi)), col = color, pch = 19, cex = 0.2)
  98. }
  99. text(-11, -11, "co", cex = 0.7)
  100.  
  101.  
  102. dev.off()
Add Comment
Please, Sign In to add comment