トップ 履歴 一覧 Farm ソース 検索 ヘルプ PDF RSS ログイン

geom_boxplot()

*disclaimer
613026

R
ggplot2

geom_boxplot()


library(ggplot2)

g <- ggplot(dat.all.size)
g <- g + aes(x=Year, y=size)
g <- g + geom_boxplot()
plot(g)

jitter

g <- g + geom_jitter(size = 0.5)

plot(g)の前に加えると分布がわかりやすい。

色 オプション fill=Year

g <- g + aes(x=Year, y=size, fill=Year)


軸ラベルを変える

g <- g + theme_bw() + ylab("Utterances") + xlab("Year")

y軸の範囲を指定 coord_cartesian(ylim=(c(0,65)))

g <- g + theme_bw() + ylab("Utterances") + xlab("Year") + coord_cartesian(ylim=(c(0,65)))


y軸の間隔を設定

+ scale_y_continuous(breaks = seq(0, 65, by = 5))


グラフの中に線を引く

g <- g + geom_hline(yintercept=c(25, 50))
  • y軸の25と50のところに横線を引く