ggplot2 中級データ可視化
Rick Scavetta
Founder, Scavetta Academy
| 過密描画の原因 | 解決策 | |
|---|---|---|
| 1. | 大規模データ | 透明度(Alpha)、中抜き点、点サイズ |
| 2. | 単一軸上に値が整列 | 上記に加え、位置を変更 |
| 3. | 低精度データ | 位置: ジッター |
| 4. | 整数データ | 位置: ジッター |
| 過密描画の原因 | 解決策 | ここでは… | |
|---|---|---|---|
| 1. | 大規模データ | 透明度(Alpha)、中抜き点、点サイズ | |
| 2. | 単一軸上に値が整列 | 上記に加え、位置を変更 | |
| 3. | 低精度データ | 位置: ジッター | geom_count() |
| 4. | 整数データ | 位置: ジッター | geom_count() |
p <- ggplot(iris, aes(Sepal.Length,
Sepal.Width))
p + geom_point()

p + geom_jitter(alpha = 0.5,
width = 0.1,
height = 0.1)

p +
geom_count()

| geom_ | stat_ |
|---|---|
geom_count() |
stat_sum() |
p +
stat_sum()

ggplot(iris, aes(Sepal.Length,
Sepal.Width,
color = Species)) +
geom_count(alpha = 0.4)

ggplot(iris, aes(Sepal.Length,
Sepal.Width,
color = Species)) +
geom_count(alpha = 0.4)
library(AER)
data(Journals)
p <- ggplot(Journals,
aes(log(price/citations),
log(subs))) +
geom_point(alpha = 0.5) +
labs(...)
p

p +
geom_quantile(quantiles =
c(0.05, 0.50, 0.95))

| geom_ | stat_ |
|---|---|
geom_count() |
stat_sum() |
geom_quantile() |
stat_quantile() |
ggplot2 中級データ可視化