tidyverts / fabletools

General fable features useful for extension packages
http://fabletools.tidyverts.org/
89 stars 31 forks source link

`autoplot()` legend removed by `ggplotly()` #394

Closed AdamSpannbauer closed 4 months ago

AdamSpannbauer commented 4 months ago

I realize this might be out of scope.

I find ggplotly() a great tool for quickly investigating irregularities via hover, and I like to encourage my students to use it; however, the autoplot() legends disappear in the conversion to plotly losing all value in cases of plotting multiple series.

My hunch is that this is due to the color mapping quosure ^interaction(___, sep = "/"). Can anyone provide insight into what's happening and/or how I might be able to overcome it?

library(fpp3)
library(plotly)

data("aus_production")

long_prod <- aus_production %>% 
  pivot_longer(-Quarter)

# Expected chart with legend
long_prod %>% 
  autoplot()

# Expected chart with no legend
long_prod %>% 
  autoplot() %>% 
  ggplotly()
mitchelloharawild commented 4 months ago

I can't reproduce this with the latest versions of fabletools, plotly, and ggplot2. The legend still appears in the plotly output as it does with the ggplot2 plot. Perhaps try updating your packages? Let me know if this is still a problem after updating.

ggplot2 image

plotly image

AdamSpannbauer commented 4 months ago

@mitchelloharawild Can't believe I didn't think to do that. Works now on my end! Thanks!!

mitchelloharawild commented 4 months ago

No worries, glad it worked out for you and it's nice to hear that you're using fable for teaching! :rocket: