Concepts of the {ggplot2}
Package Pt. 1:
Solution Exercise 1
geom_line()
and geom_path()
?g <- ggplot(
filter(bikes, is_weekend == TRUE),
aes(x = date, y = count)
) +
geom_line(
aes(group = day_night),
color = "grey"
) +
geom_point(
aes(color = day_night,
shape = day_night)
)
g +
theme_minimal(
base_size = 15,
base_family = "Lora"
) +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
)
ggplot(
filter(bikes, is_weekend == TRUE),
aes(x = date, y = count)
) +
geom_line(
aes(group = day_night),
color = "grey"
) +
geom_point(
aes(color = day_night,
shape = lubridate::day(date) == 6)
) +
labs(
x = "Weekend date",
y = "Reported bike shares",
color = NULL,
shape = NULL
) +
theme_minimal(
base_size = 15,
base_family = "Lora"
) +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
)
ggplot(
filter(bikes, is_weekend == TRUE),
aes(x = date, y = count)
) +
geom_line(
aes(group = day_night),
color = "grey"
) +
geom_point(
aes(color = day_night,
shape = lubridate::wday(date, label = TRUE))
) +
labs(
x = "Weekend date",
y = "Reported bike shares",
color = NULL,
shape = NULL
) +
theme_minimal(
base_size = 15,
base_family = "Lora"
) +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
)
invisible(
Sys.setlocale("LC_TIME", "C")
)
ggplot(
filter(bikes, is_weekend == TRUE),
aes(x = date, y = count)
) +
geom_line(
aes(group = day_night),
color = "grey"
) +
geom_point(
aes(color = day_night,
shape = lubridate::wday(date, label = TRUE))
) +
labs(
x = "Weekend date",
y = "Reported bike shares",
color = NULL,
shape = NULL
) +
theme_minimal(
base_size = 15,
base_family = "Lora"
) +
theme(
legend.position = "top",
panel.grid.minor = element_blank()
)
Cédric Scherer // rstudio::conf // July 2022