Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
生成统计之都主站的占位缩略图
## setwd('path/to/magnificent/images/noimage')
set.seed(123)
png("thumbnail%d.png", width = 73, height = 73)
par(mar = rep(0, 4), ann = FALSE, xaxt = "n", yaxt = "n")
hist(rnorm(100), main = "", col = heat.colors(8))
boxplot(list(rnorm(100), runif(100)), col = 2:3)
sunflowerplot(iris[, 1:2], pch = 20, col = "gold", size = 1/20)
lines(lowess(iris[, 1], iris[, 2]), lwd = 2, col = rgb(0, 1, 0, 0.5))
smoothScatter(iris[, 1:2])
contour(volcano, nlevels = 6, drawlabels = FALSE)
fourfoldplot(margin.table(aperm(UCBAdmissions, c(2, 1, 3)), c(1, 2)))
image(t(volcano)[ncol(volcano):1, ])
mosaicplot(~gear + carb, data = mtcars, color = TRUE, las = 1, main = "",
xlab = "", ylab = "")
z <- 4 * volcano
x <- 10 * (1:nrow(z))
y <- 10 * (1:ncol(z))
persp(x, y, z, theta = 135, phi = 30, col = "green3", scale = FALSE, ltheta = -120,
shade = 0.75, border = NA, box = FALSE)
stars(mtcars[1:9, 1:7], labels = NULL, col.stars = terrain.colors(9))
## 波波头一头
library(sna)
gplot(rgraph(10, tprob = runif(10, 0.1, 0.3)), vertex.sides = 4, vertex.lty = 0,
vertex.cex = runif(10, 5, 10), usearrows = F, edge.col = grey(runif(10, 0.6,
0.8)), vertex.col = sample(rainbow(10), re = T))
text(2.2, 2.4, "bo", cex = 0.7)
## 王晓伟
r <- runif(1, 0.25, 0.75)
d <- runif(1, 0.25 * r, r)
t <- 2 * pi * seq(0, 10, by = 0.1)
x <- (1 - r) * cos(t) + d * cos((1 - r) * t/r)
y <- (1 - r) * sin(t) - d * sin((1 - r) * t/r)
plot(x, y, type = "l", col = "blue", lwd = 0.5)
text(-0.8, 0.8, "w", cex = 0.7)
## 主伟呈
x = rnorm(100)
y = x^2 + runif(100, 0, 3)
zones = matrix(c(2, 0, 1, 3), ncol = 2, byrow = T)
layout(zones, widths = c(2/3, 1/3), heights = c(1/3, 2/3))
xhist = hist(x, plot = F)
yhist = hist(y, plot = F)
top = max(c(xhist$counts, yhist$counts))
par(mar = c(0.2, 0.2, 0, 0))
plot(x, y, xlim = c(min(x), max(x)), ylim = c(min(y), max(y)), pch = 20,
col = "grey70")
text(mean(x), quantile(y, prob = 0.98), "z", cex = 0.7)
lines(lowess(x, y), col = "grey40")
par(mar = c(0, 0.2, 0, 0))
barplot(xhist$counts, axes = F, ylim = c(0, top), space = 0, col = "green")
par(mar = c(0.2, 0, 0, 0))
barplot(yhist$counts, axes = F, xlim = c(0, top), space = 0, horiz = T,
col = "yellow")
layout(1)
## 邱怡轩
par(mar = rep(0, 4), ann = FALSE, xaxt = "n", yaxt = "n")
pie(c(1, 1, 2, 3, 3), labels = "", col = rainbow(5), radius = 1, border = "white")
theta = 0.1 * pi
text(0.75 * cos(theta), 0.75 * sin(theta), "A", col = "white")
theta = 0.3 * pi
text(0.75 * cos(theta), 0.75 * sin(theta), "C", col = "white")
theta = 0.6 * pi
text(0.75 * cos(theta), 0.75 * sin(theta), "I", col = "white")
theta = 1.1 * pi
text(0.75 * cos(theta), 0.75 * sin(theta), "S", col = "white")
theta = 1.7 * pi
text(0.75 * cos(theta), 0.75 * sin(theta), "T", col = "white")
text(0.9, 0.9, "q", cex = 0.7)
## cogitovita
rot = function(x, y, theta) {
x1 = sin(theta) * x + cos(theta) * y
y1 = -cos(theta) * x + sin(theta) * y
list(x = x1, y = y1)
}
x = runif(1000, -7, 7)
y = x + runif(1, 3, 5)
plot(x, y, xlim = c(-14, 14), ylim = c(-14, 14), type = "n")
n = 99
# copy color function from Xie Laoda!
color = apply(replicate(2 * n, sample(c(0:9, LETTERS[1:6]), 8, replace = TRUE)),
2, function(x) sprintf("#%s", paste(x, collapse = "")))
for (i in 1:n) {
points(rot(x, y, runif(1, -pi, pi)), col = color, pch = 19, cex = 0.2)
}
text(-11, -11, "co", cex = 0.7)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.