3D棒グラフは,棒の高さを読み取るのが難しいので, あまり推奨されないグラフなのですが,ちょっと分布の様子を眺めるには便利だったりもします。 とくに,視点場を自在に変えながら,様々な方向からグラフを眺めたほうがわかりやすいと思います。 そこでrglで3D棒グラフを描いてみます。

library(httr)
library(readxl)
uri <- "http://www.city.kitakyushu.lg.jp/page/toukei/sougou/tyouki/02/0210.xls"
GET(uri, write_disk("0210.xls", overwrite=TRUE))
tmp <- read_excel("0210.xls", skip=6, col_names=FALSE, col_types=c("text", c(rep("numeric", 11)), "text"))
tmp <- tmp[complete.cases(tmp),]
tmp <- subset(tmp, X1!='総数')
dat <- data.frame(year=factor(rep(seq(1965, 2010, 5), each=15)), age=factor(tmp$X1), population=tmp$X2)
dat <- xtabs(population ~ year + age, dat)

ソースファイルはgistに置いてあります。

library(devtools)
source_gist("https://gist.github.com/kzktmr/01c25068df145aa0b97f")
## Sourcing https://gist.githubusercontent.com/kzktmr/01c25068df145aa0b97f/raw/a0710f91fdad6698fc76aed339f98460f9944cf0/barplot3d.R
## SHA-1 hash of file is ccce2191cd55815a2d37b7dc9734e6c269a42f8a

3D棒グラフ。マウスでグリグリ動きます。

barplot3d(dat, scale=.5)

You must enable Javascript to view this page properly.