Customizing the tooltip for a plotly version of a geom_mosaic plot
Opened this issue · 0 comments
DragonflyStats commented
This query relates to customising the tooptip for a plotly version of a mosaic plot, derived using the ggplotly command.
Starting with the canonical example
library(ggmosaic)
p <- ggplot(data = fly) +
geom_mosaic(aes(x = product(rude_to_recline), fill=do_you_recline)) +
theme_mosaic()
and then using ggplotly
from {plotly}
library(plotly)
ggplotly(p)
we can create an interactive version of the mosaic plot.
The question relates to the tooltip. What you see when you hover over each cell in the plot.
For the top left, the tool tip text will read as
always
no
Frequency: 124
Is there a way of customising the tooltip text?
Similar examples for Barcharts would be along the lines of the code below
p <- ggplot(data = fly) +
geom_mosaic(aes(x = product(rude_to_recline), fill=do_you_recline,
text=paste("\n Rude to Recline?:",rude_to_recline,"\nDo you recline?",do_you_recline")
)) +
theme_mosaic()
ggplotly(p, tooltip="text")