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

view_follow keeps x-axis fixed while in transition #88

Closed
kanishkamisra opened this issue Jul 7, 2018 · 5 comments
Closed

view_follow keeps x-axis fixed while in transition #88

kanishkamisra opened this issue Jul 7, 2018 · 5 comments

Comments

@kanishkamisra
Copy link
Contributor

Was writing an example for view_follow to show log transformation effects on data:

library(tidyverse)
library(gapminder)
library(gganimate)

gapminder %>%
  filter(year == 2007) %>%
  mutate(log_gdp = log(gdpPercap)) %>%
  gather(gdpPercap, log_gdp, key = "gdp_scale", value = "value") %>%
  ggplot() +
  geom_density(aes(value)) +
  transition_states(gdp_scale, transition_length = 4, state_length = 1) +
  view_follow()

I get this:
gganimate_issue

The x-axis remains constant while y changes appropriately (even though fixed_x is FALSE by default). Am I doing this wrong? Any ideas on how I can fix this?

@thomasp85
Copy link
Owner

It seems the density curve keeps the full range at all time so the view is doing the right thing. Try with a non-density example

@kanishkamisra
Copy link
Contributor Author

Histogram also doesn't seem to work:

library(tidyverse)
library(gapminder)
library(gganimate)

gapminder %>%
  filter(year == 2007) %>%
  mutate(log_gdp = log(gdpPercap)) %>%
  gather(gdpPercap, log_gdp, key = "gdp_scale", value = "value") %>%
  ggplot() +
  geom_histogram(aes(value)) +
  transition_states(gdp_scale, transition_length = 3, state_length = 2) +
  view_follow()

preview_histogram

However, this works (like you said):

library(tidyverse)
library(gapminder)
library(gganimate)

gapminder %>%
  filter(year == 2007) %>%
  mutate(log_gdp = log(gdpPercap)) %>%
  gather(gdpPercap, log_gdp, key = "gdp_scale", value = "value") %>%
  ggplot(aes(value, lifeExp)) +
  geom_point() +
  transition_states(gdp_scale, transition_length = 2, state_length = 1) +
  view_follow()

preview2

@thomasp85
Copy link
Owner

I think the "problem" is that the different binning and density transformations keep data even if it is zero, so the view can't zoom in more...

I'll keep it open as it would be nice to solve but it is not obvious how it should be done

@thomasp85
Copy link
Owner

Closing - don't think this should be solved in gganimate

@shaggycamel
Copy link

shaggycamel commented Jan 22, 2025

Anyone know if this has been fixed, or an alternative found?

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

3 participants