Skip to content

gganimate not working with geom_area() #418

@AshesITR

Description

@AshesITR

This looks related to #269, feel free to dupe-close if it's identical.

I'm trying to have a constant background reference plot using

  • separate data and
  • geom_area

This causes a crash related to -data$group.
Examining the stack trace suggests that the group aesthetic is assumed to be integer but something before the crashing code creates character groups instead.

data$group is constant and equal to "1" at the point of failure.
The failing function is positon_stack so geom_area is likely not the only affected geom.

library(gganimate)
library(dplyr)

p <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, group = Species, color = Species)) %+%
  geom_area(
    aes(group = NULL, color = NULL),
    data = iris %>%
      group_by(Sepal.Length) %>%
      summarise(Sepal.Width = mean(Sepal.Width)),
    alpha = 0.5
  ) %+%
  geom_point()

p

p %+%
  transition_states(Species) %>%
  animate(renderer = gifski_renderer(file = "temp.gif"))
#> Error in -data$group: invalid argument to unary operator

Created on 2020-10-29 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions