plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

Hoverlabels in stacked area charts with ggplotly not working properly

Open acmuehlhausen-smc opened this issue 2 years ago • 3 comments

Hello there!

When creating a stacked area chart with ggplot in R and using ggplotly to create a plotly version of it, there occurs a rather grave error: in the hoverlabel only the frist value for each trace is shown. Say, I have years on the x axis, then for all years 2019 will be displayed, even though the value belongs to 2023.

My minimum code sample is here: https://plotly.com/ggplot2/filled-area-plots/

The official tutorials samples show the same behaviour on my Linux machine, all packages up to date.

Would really enjoy it if that were to be fixed!

Best regards! Alex

acmuehlhausen-smc avatar Jan 18 '23 15:01 acmuehlhausen-smc

Hi

I have the same problem after I updated ggplot. I suspect it's because of the new stat_align function that is now behind the geom_area functions.

https://www.tidyverse.org/blog/2022/11/ggplot2-3-4-0/

I have no idea if this is an ggplot2 issue or plotly issue, but I too would love the issue to be fixed.

I just found away around this bug though. If you use geom_area(stat = "identity") it will work again in ggplotly. If you don't want to do that everytime you could update the geom defults:

update_geom_defaults("area", stat = "identity"))

or

geom_area <- function(stat = "identity", ...){ggplot2::geom_area(stat = stat, ...)}

karsfri avatar Feb 20 '23 14:02 karsfri

Hi,

thanks for the input, will try that sometime! For the moment, I am working with Python Plotly now, it has ... different bugs. ;-)

acmuehlhausen-smc avatar Mar 01 '23 13:03 acmuehlhausen-smc

Hi

I have the same problem after I updated ggplot. I suspect it's because of the new stat_align function that is now behind the geom_area functions.

https://www.tidyverse.org/blog/2022/11/ggplot2-3-4-0/

I have no idea if this is an ggplot2 issue or plotly issue, but I too would love the issue to be fixed.

I just found away around this bug though. If you use geom_area(stat = "identity") it will work again in ggplotly. If you don't want to do that everytime you could update the geom defults:

update_geom_defaults("area", stat = "identity"))

or

geom_area <- function(stat = "identity", ...){ggplot2::geom_area(stat = stat, ...)}

This worked for me!

federicotallis avatar Oct 29 '23 20:10 federicotallis