在 R/plotly 中,如何更改工具提示格式?如下圖,工具提示 'Sales' 顯示 '0.230',如何將其轉換為 '23.0%' 。謝謝!
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'))

uj5u.com熱心網友回復:
您可以嘗試使用 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'))

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/369336.html
上一篇:獲取多個CSV檔案的行數和列數
下一篇:如何在`survminer`包的`ggcompetingrisks`中用`geom_errorbar`替換默認的`geom_ribbon`?
