library(ggplot2)
library(dplyr)
library(gganimate)
library(tidyverse)
library(ggthemes)
## Graph 1 
data("iris")
iris2<- ggplot(iris, aes(x= Petal.Width,y=Petal.Length)) + labs(x="Petal Width", y="Petal Length") +
  geom_point()


#transition
anim <- iris2 +
  transition_states(Species,
                    transition_length =  3, #transition duration
                    state_length = 3)
anim +
  ggtitle(' Now showing {closest_state}') # titlling to clairfy what frame it is on 

## graph 2
anim2<- ggplot(iris, mapping = aes(x= Petal.Width,y=Petal.Length)) +
  labs(x= "Petal Width",y ="Petal Length")+
  geom_point(aes(color = Species)) +
  transition_states(Species,
                    transition_length =  3,
                    state_length = 3)

anim2_editFade<- anim2 +
  enter_fade()+ # make transition look nicer - fade in/shrink out
  exit_shrink()

anim2_editedFade_title <- anim2_editFade +
  ggtitle(' Now showing {closest_state}') # titlling to clairfy what frame it is on 

final_anim <- anim2_editedFade_title + theme_solarized()

final_anim