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

Strange dataset dependent grouping effect #266

Closed
clauswilke opened this issue Jan 7, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@clauswilke
Copy link
Contributor

commented Jan 7, 2019

This works:

library(ggplot2)
library(ungeviz)    # devtools::install_github("wilkelab/ungeviz")
library(gganimate)

ggplot(iris, aes(Sepal.Length, Sepal.Width, colour = Species)) +
  geom_point() +
  stat_smooth_draws(
    times = 10,
    formula = y ~ x,
    aes(group = interaction(stat(.draw), colour)),
    size = 1.5
  ) +
  theme_bw() + theme(legend.position = "bottom") + 
  transition_states(stat(.draw), 1, 2) +
  enter_fade() + exit_fade()

iris

This doesn't (lines are now connected):

ggplot(mtcars, aes(disp, mpg, colour = factor(cyl))) +
  geom_point() +
  stat_smooth_draws(
    times = 10,
    formula = y ~ x,
    aes(group = interaction(stat(.draw), colour)),
    size = 1.5
  ) +
  theme_bw() + theme(legend.position = "bottom") + 
  transition_states(stat(.draw), 1, 2) +
  enter_fade() + exit_fade()

mtcars

Notice that the only difference is the data set. I have tried as.character(cyl) instead of factor(cyl) to see if the problem is the numeric variable turned into a factor, and it makes no difference.

@thomasp85 thomasp85 closed this in a326ce9 Jan 7, 2019

@thomasp85

This comment has been minimized.

Copy link
Owner

commented Jan 7, 2019

At least you can't complain the fixes aren't coming fairly quickly :-)

@clauswilke

This comment has been minimized.

Copy link
Contributor Author

commented Jan 7, 2019

I'm not complaining. Thanks for all your effort on this. shadow_mark() looks much better now with geom_smooth()!

@thomasp85

This comment has been minimized.

Copy link
Owner

commented Jan 7, 2019

Dont worry - just joking 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.