Formatting big numbers in plotly graph

Viewed 323

I'm working in R with plot_ly. In the graph, by default, plot_ly adds K, M and B for thousands, millions and billions respectively.

This is an American convention and I need European/British convention which is k, m, bn. I also want to remove 2 and 5 tickmarks in a logarithmic scale.

Reproducible example:

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"))

What I have:

enter image description here

What I want:

enter image description here

What I've tried:

xaxis = list(
  ticktext = list("10m", "100m", "1bn", "10bn"), 
  tickvals = list(10*10^6, 100*10^6, 10^9, 10*10^9),
  tickmode = "array"
)

but it doesn't work with type = "log".

0 Answers
Related