Introducción a la visualización de datos con ggplot2
Rick Scavetta
Founder, Scavetta Academy
| Tipo de gráfico | Geomas posibles |
|---|---|
| Diagramas de dispersión | points, jitter, abline, smooth, count |
| Gráficos de barras | histogram, bar, col, errorbar |
| Gráficos lineales | 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()
# Default bin width:
diff(range(iris$Sepal.Width))/30
[1] 0.08

ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.1)
Establece siempre una anchura de recipiente significativa para tus datos.
Sin espacios entre barras.

ggplot(iris, aes(x = Sepal.Width)) +
geom_histogram(binwidth = 0.1,
center = 0.05)
Establece siempre una anchura de recipiente significativa para tus datos.
Sin espacios entre barras.
Las etiquetas del eje X están entre las barras.

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

Introducción a la visualización de datos con ggplot2