r - 在绘图图中格式化大数字
问题描述
我正在使用 plot_ly 在 R 中工作。在图中,默认情况下,plot_ly 分别为千、百万和十亿添加 K、M 和 B。
这是一个美国公约,我需要欧洲/英国公约,即 k、m、bn。我还想以对数刻度删除 2 和 5 个刻度线。
可重现的例子:
library(plotly)
data <- data.frame(
value1 = c(10^6, 10^7, 10^8, 10^9),
value2 = c(10^6, 10^7, 10^8, 10^9)
)
plot_ly(data = data, x = ~value1, y = ~value2, type = "scatter", mode = "markers") %>%
layout(xaxis = list(type = "log"),
yaxis = list(type = "log"))
我有的:
我想要的是:
我试过的:
xaxis = list(
ticktext = list("10m", "100m", "1bn", "10bn"),
tickvals = list(10*10^6, 100*10^6, 10^9, 10*10^9),
tickmode = "array"
)
但它不适用于 type = "log"。