Introdução à visualização de dados com ggplot2
Rick Scavetta
Founder, Scavetta Academy
Ajuste para sobreposição
ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point()

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "identity")

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "jitter")

posn_j <- position_jitter(0.1)
ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
col = Species)) +
geom_point(position = posn_j)

posn_j <- position_jitter(0.1,
seed = 136)
ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = posn_j)

scale_x_*()scale_y_*()scale_color_*()scale_colour_*()scale_fill_*()scale_shape_*()scale_linetype_*()scale_size_*()scale_x_continuous()scale_y_*()scale_color_discrete()scale_colour_*()scale_fill_*()scale_shape_*()scale_linetype_*()scale_size_*()ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "jitter") +
scale_x_continuous("Sepal Length") +
scale_color_discrete("Species")

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "jitter") +
scale_x_continuous("Sepal Length",
limits = c(2,8)) +
scale_color_discrete("Species")

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "jitter") +
scale_x_continuous("Sepal Length",
limits = c(2, 8),
breaks = seq(2, 8, 3)) +
scale_color_discrete("Species")

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "jitter") +
scale_x_continuous("Sepal Length",
limits = c(2, 8),
breaks = seq(2, 8, 3),
expand = c(0, 0)) +
scale_color_discrete("Species")

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "jitter") +
scale_x_continuous("Sepal Length",
limits = c(2, 8),
breaks = seq(2, 8, 3),
expand = c(0, 0),
labels = c("Setosa",
"Versicolor",
"Virginica")) +
scale_color_discrete("Species")

ggplot(iris, aes(x = Sepal.Length,
y = Sepal.Width,
color = Species)) +
geom_point(position = "jitter") +
labs(x = "Sepal Length",
y = "Sepal Width",
color = "Species")

Introdução à visualização de dados com ggplot2