Issue with R Animation: missing axis labels and tick marks

116 Views Asked by At

I've just begun to explore animations using ggplot2 and gganimate, and in multiple use cases I'm finding that elements like legends and axis labels are being omitted from the final animation. For example, if I run the following code...

anim <- ggplot(iris,aes(Petal.Width,Petal.Length)) + 
  geom_point(aes(color=Species), size=2) 

anim

...the output contains all of the expected formatting elements like axis labeling and legend:

axis labeling and legend intact

However, if I continue to add animation elements with the below code, the output omits the axis labeling and legend.

anim <- ggplot(iris,aes(Petal.Width,Petal.Length)) + 
  geom_point(aes(color=Species), size=2) + 
  transition_states(Species,transition_length = 2, state_length = 1) 

anim+enter_fade()+exit_disappear()

missing axis labels and legend

I expected the animated plot to mirror my the ggplot output prior to adding animation effects. I tried adding scale_x_continuous at the very end but this did not yield the desired effect.

Curious if I've omitted a key argument here. Appreciate any and all help.

0

There are 0 best solutions below