There was an error while loading. Please reload this page.
You can add interactive hover-based tooltips by pairing ggplot2::ggplot with plotly::ggplotly. The basic workflow is:
ggplot2::ggplot
plotly::ggplotly
p <- ggplot(... aes(..., text = <variable and/or text you want>), ...) ggplotly(p, tooltip = "text")
p <- ggplot(... aes(..., text = <variable and/or text you want>), ...)
ggplotly(p, tooltip = "text")
Reprex:
df = data.frame(xval=1:10, yval=sample(1:10, 10), zval=sample(c("this", "that"), 10, replace=T)) p <- ggplot(data = df, aes(x=xval, y=reorder(yval, xval), text=paste("Group: ", zval))) + geom_bar(stat="identity", fill="lightsteelblue") + labs(title = "Example of tooltip") ggplotly(p, tooltip = "text")