Lattice and ggplot graphics, side by side 実践4 単変量分布の描図

dev.off()

# dataとしてfaithfulを指定している
# 1変量eruptionsを指定している
pl <- densityplot(~eruptions, data = faithful)
print(pl)

dev.new()
# 1変量eruptionsを指定している
# position_jitter(height = )は、下部に並ぶ点の高さの幅を指定している
p <- ggplot(faithful, aes(eruptions))
pg <- p + stat_density(geom = "path", position = "identity") + geom_point(aes(y = 0.05), position = position_jitter(height = 0.005), alpha = 0.25)
print(pg)

    • position_jitter(height = )を変えると以下の通り
p <- ggplot(faithful, aes(eruptions))
pg <- p + stat_density(geom = "path", position = "identity") + geom_point(aes(y = 0.05), position = position_jitter(height = 0.05), alpha = 0.25)
print(pg)

  • だいたいわかった。ggplot2の方が性に合うように思う