Open
Description
Description
When converting a ggplot2
plot to plotly using ggplotly()
, the generated tooltip does not contain aesthetic entry if its name is equal to 'group'.
Would it be like there are some 'reserved' word that can't be used as aesthetic names, in order for the tooltip generation to work correctly ?
Reproducible example
library(ggplot2)
library(plotly)
data(iris)
p1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, col = Species)) +
geom_point()
p1
ggplotly(p1, tooltip = "Species")
# => works fine!
iris2 <- iris
iris2$group <- iris2$Species
p2 <- ggplot(iris2, aes(x = Sepal.Length, y = Sepal.Width, col = group)) +
geom_point()
p2
ggplotly(p2, tooltip = "group")
# => does not show 'group' in tooltip
ggplotly(p2, tooltip = "all")
# => shows 'Sepal.Length' and 'Sepal.Width', but not 'group' in tooltip
Environment information
R version 4.4.2 (2024-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
time zone: Europe/Berlin
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plotly_4.10.4 ggplot2_3.5.1
loaded via a namespace (and not attached):
[1] vctrs_0.6.5 httr_1.4.7 cli_3.6.3 rlang_1.1.4 purrr_1.0.2 generics_0.1.3 jsonlite_1.8.9
[8] data.table_1.16.4 labeling_0.4.3 glue_1.8.0 colorspace_2.1-1 htmltools_0.5.8.1 scales_1.3.0 grid_4.4.2
[15] crosstalk_1.2.1 munsell_0.5.1 tibble_3.2.1 fastmap_1.2.0 yaml_2.3.10 lifecycle_1.0.4 compiler_4.4.2
[22] dplyr_1.1.4 htmlwidgets_1.6.4 pkgconfig_2.0.3 tidyr_1.3.1 rstudioapi_0.17.1 farver_2.1.2 digest_0.6.37
[29] viridisLite_0.4.2 R6_2.5.1 tidyselect_1.2.1 pillar_1.10.1 magrittr_2.0.3 tools_4.4.2 withr_3.0.2
[36] gtable_0.3.6 lazyeval_0.2.2
Metadata
Metadata
Assignees
Labels
No labels