I wanted to create a histogram with legends above these bars. the legends represents the average hours of sleep per day.
ggplot(average_sleep_per_day) +
geom_col(aes(x = reorder(day, average_sleep), y = average_sleep, fill = average_sleep)) +
labs(title = "average_sleep_per_day") +
theme_classic() +
theme(panel.background = element_blank(),
plot.title = element_text(hjust = 0.5, size=10, face = "bold")) +
geom_text(aes(label = round(average_sleep, 1)),
position = position_stack(vjust = 1.02))
My data:
average_sleep_per_day <- structure(
list(
day = c("Dimanche", "Jeudi", "Lundi"),
average_sleep = c(7.54575757575758, 6.68828125, 6.99166666666667)
),
row.names = c(NA, -3L), class = c("tbl_df", "tbl", "data.frame")
)