I want to keep the labels from geom_col
when you hover over the columns, but remove the labels from geom_text
(shown below).
How can I do this?
library(tidyverse)
library(plotly)
data <- iris %>%
pivot_longer(-Species, names_to = "indicator", values_to = "value") %>%
rename(species = Species) %>%
group_by(species, indicator) %>%
summarise(value = sum(value))
graph <- ggplot(data, aes(indicator, value, fill = species)) +
geom_col(aes(text = paste0("Species:", species,
"</br></br>Indicator:", indicator,
"</br>Value:", value))) +
geom_text(aes(label = value),
position = position_stack(vjust = 0.5))
ggplotly(graph, tooltip = "text")