Introduction à la visualisation de données avec ggplot2
Rick Scavetta
Founder, Scavetta Academy
| Type de graphique | Géoms possibles |
|---|---|
| Nuages de points | points, jitter, abline, smooth, count |
| Graphiques à barres | histogram, bar, col, errorbar |
| Graphiques linéaires | 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()
# Largeur de classe par défaut :
diff(range(iris$Sepal.Width))/30
[1] 0.08

ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.1)
Définissez toujours des largeurs de classe pertinentes pour vos données.
Aucune espace entre les barres.

ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.1,
center = 0.05)
Définissez toujours des largeurs de classe pertinentes pour vos données.
Aucune espace entre les barres.
Les étiquettes de l'axe X sont entre les barres.

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")

Introduction à la visualisation de données avec ggplot2