Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition_reveal + geom_text assume ordered column to work #323

Closed
osiris08 opened this issue Jun 3, 2019 · 1 comment
Closed

transition_reveal + geom_text assume ordered column to work #323

osiris08 opened this issue Jun 3, 2019 · 1 comment

Comments

@osiris08
Copy link

osiris08 commented Jun 3, 2019

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))
@awgymer
Copy link

awgymer commented Jul 2, 2019

I just found this same problem using transition_reveal(x) with geom_step and geom_point. With an unordered dataframe my animation had multiple points plotted in every frame, and the step path had a weird tail. Ordering the dataframe by my x column solved everything. Did I just miss this in the documentation or is it not stated?

VolodiaPG pushed a commit to VolodiaPG/gganimate that referenced this issue May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants