In R/plotly, how to change the tooltip format? As below image, the tooltip 'Sales' show '0.230', how to transfer it to '23.0%' . Thanks!
library(ggplot2)
library(plotly)
mydata <- data.frame(
category=LETTERS[1:5],
sales=c(0.234,0.23,0.17,0.4,0.35)
)
p <- ggplot(mydata,aes(x=category,y=sales))
geom_point()
ggplotly(p,tooltip=c('y','x'))
CodePudding user response:
You may try using scales::percent
library(scales)
p <- mydata %>%
mutate(sales = scales::percent(sales)) %>%
ggplot(aes(x=category,y=sales))
geom_point()
ggplotly(p,tooltip=c('y','x'))