Reputation: 309
I have this piece of code.
How can I please easy change hover text diff
to newlabel
?
Here is my site http://webcovid19.online/
ggplotly(
ggplot(my_data, aes(x=date, y=diff)) +
geom_bar(stat='identity',fill='red') +
scale_y_continuous(labels = comma)
)
Upvotes: 1
Views: 1893
Reputation: 30474
You can customize the text in the tooltip adding text
to your aes()
in ggplot
. Here, you can include both date
and diff
with whatever text label you want (or just include diff
alone). Within ggplotly
, you can include tooltip = "text"
to refer to this text with hover.
library(plotly)
library(scales)
ggplotly(
ggplot(my_data, aes(x=date, y=diff, text = paste("Date:", date, "\nnewlabel:", diff))) +
geom_bar(stat='identity', fill='red') +
scale_y_continuous(labels = comma),
tooltip = "text"
)
Upvotes: 2