-
Notifications
You must be signed in to change notification settings - Fork 316
Closed
Description
In order to reveal lines with correct geom_text label, transition_reveal needs the table to be ordered to work. In the following example, I shuffled the data, and it cannot show labels correctly.
It's very often data comes in with shuffled order, and it's difficult to know this assumption.
airq <- airquality %>% dplyr::sample_n(153)
airq$Month <- format(ISOdate(2004,1:12,1),"%B")[airq$Month]
ggplot(airq, aes(Day, Temp, group = Month)) +
geom_line() +
geom_segment(aes(xend = 31, yend = Temp), linetype = 2, colour = 'grey') +
geom_point(size = 2) +
geom_text(aes(x = 31.1, label = Month), hjust = 0) +
transition_reveal(Day) +
coord_cartesian(clip = 'off') +
labs(title = 'Temperature in New York', y = 'Temperature (°F)') +
theme_minimal() +
theme(plot.margin = margin(5.5, 40, 5.5, 5.5))
z3tt
Metadata
Metadata
Assignees
Labels
No labels