3.12. 自チームと相手チームを重ねて描画
# ggplot2 パッケージを使用
library(ggplot2)
# ヒストグラムを描画
g <- ggplot(d)
g <- g + geom_histogram(
aes(
x=d$"自チーム.10分あたりのTOUCH数",
y=..density..,
colour= "自チーム",
fill="自チーム"
),
binwidth=5,
alpha=0.3,
position="identity"
)
g <- g + geom_histogram(
aes(
x=d$"相手チーム.10分あたりのTOUCH数",
y=..density..,
colour= "相手チーム",
fill="相手チーム"
),
binwidth=5,
alpha=0.3,
position="identity"
)
# タイトルを変更
g <- g + labs(title="10分あたりのボールタッチ回数")
g <- g + xlab("ボールタッチ")
g <- g + ylab("確率密度")
g <- g + labs(colour="凡例", fill="凡例")
# テーマを指定
g <- g + theme_bw()
# 色を指定
g <- g + scale_color_manual(values=c(BLUE_5, PINK_5))
g <- g + scale_fill_manual( values=c(BLUE_5, PINK_5))
print(g)