3 次元マトリックスを視覚化するにはどうすればよいですか?
- 最初の次元は x 座標 = 異なる大学
- 2 番目の次元は y 座標 = 分野または専門分野 (物理学、数学、芸術など)
- 3 番目の次元は色 = 別の年
- 円の大きさ = 対応する分野/大学の論文数
次のようなデータがあるとします。
set.seed(911)
mat = tapply(sample(0:200, 5*10*16, TRUE, prob = rev(prop.table(0:200))),
expand.grid(univ = paste("univ", 1:5, sep = ""),
dis = paste("dis", 1:10, sep = ""),
yr = 2000:2015),
I)
次の行に沿って何かを試すことができます。
#convert to easy to manipulate format
DF = as.data.frame(as.table(mat))
#x
xlvs = unique(DF$univ)
xx = match(DF$univ, xlvs)
#y
ylvs = unique(DF$dis)
yy = match(DF$dis, ylvs)
#colors
collvs = unique(DF$yr)
cols = terrain.colors(length(collvs), alpha = 0.75)[match(DF$yr, collvs)]
#sizes
maxcex = 5
cexs = (DF$Freq * maxcex) / max(DF$Freq)
layout(matrix(c(1, 1, 1, 1, 1, 2), nrow = 1))
#plot 1
plot(xx, yy, col = cols, cex = cexs, pch = 19, axes = FALSE, frame.plot = TRUE)
axis(1, at = seq_along(xlvs), labels = xlvs)
axis(2, at = seq_along(ylvs), labels = ylvs, las = 1)
#plot 2
par(mar = c(1, 1, 1, 4))
fill = terrain.colors(length(collvs) * 9, alpha = 0.75) #higher 'resolution' of plot
barplot(matrix(rep_len(1L, length(fill))), col = fill, border = NA, axes = FALSE)
axis(4, at = seq(1, length(fill), 9) + 4, labels = collvs, las = 1)