title: gganimate barchart: smooth transition when bar is replaced
body: <p>I want to create an animated barplot with the <code>gganimate</code> package. The barplot should contain 4 bars, but only three of the bars should be shown at the same time. When a bar drops out and a new bar comes in, the animation should be smooth (as it is when two bars switch position within the plot).</p>
  
  <p>Consider the following example:</p>
  
  <pre><code># Set seed
  set.seed(642)
  
  # Create example data
  df &lt;- data.frame(ordering = c(rep(1:3, 2), 3:1, rep(1:3, 2)),
                   year = factor(sort(rep(2001:2005, 3))),
                   value = round(runif(15, 0, 100)),
                   group = c(letters[sample(1:4, 3)],
                             letters[sample(1:4, 3)],
                             letters[sample(1:4, 3)],
                             letters[sample(1:4, 3)],
                             letters[sample(1:4, 3)]))
  
  # Load packages
  library("gganimate")
  library("ggplot2")
  
  # Create animated ggplot
  ggp &lt;- ggplot(df, aes(x = ordering, y = value)) +
    geom_bar(stat = "identity", aes(fill = group)) +
    transition_states(year, transition_length = 2, state_length = 0)
  ggp
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/akbTA.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/akbTA.gif" alt="enter image description here"></a></p>
  
  <p>If a bar is exchanged, the color of the bar just changes without any smooth animation (i.e. the new bar should fly in from the side and the replaced bar should fly out).</p>
  
  <p><strong>Question: How could I smoothen the replacement of bars?</strong></p>