Introductie tot datavisualisatie met ggplot2
Rick Scavetta
Founder, Scavetta Academy
| Plottype | Mogelijke geoms |
|---|---|
| Spreidplots | points, jitter, abline, smooth, count |
| Staafdiagrammen | histogram, bar, col, errorbar |
| Lijnplots | line, path |
ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram()
`stat_bin()` using `bins = 30`.
Pick better value with `binwidth`.

ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram()
# Standaard binklasse:
diff(range(iris$Sepal.Width))/30
[1] 0.08

ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.1)
Kies altijd een zinvolle binklasse voor je data.
Geen spaties tussen balken.

ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.1,
center = 0.05)
Kies altijd een zinvolle binklasse voor je data.
Geen spaties tussen balken.
X-aslabels staan tussen de balken.

ggplot(iris, aes(x = Sepal.Width,
fill = Species)) +
geom_histogram(binwidth = .1,
center = 0.05)

ggplot(iris, aes(x = Sepal.Width,
fill = Species)) +
geom_histogram(binwidth = .1,
center = 0.05,
position = "stack")

ggplot(iris, aes(x = Sepal.Width,
fill = Species)) +
geom_histogram(binwidth = .1,
center = 0.05,
position = "dodge")

ggplot(iris, aes(x = Sepal.Width,
fill = Species)) +
geom_histogram(binwidth = .1,
center = 0.05,
position = "fill")

Introductie tot datavisualisatie met ggplot2