How do I make the Billions unit show as B instead of G in Observable Plot?

Hi, I literally searched everywhere but I can’t find a way of using B for Billion instead of G for Giga in the Observable/plot on the legends. I’m putting together some accounting charts and I need it to say B. What is the way to do it?

Thank you.

I guess you could specify the tickFormat option and then call .replace on the resulting string , as in

Plot.plot({
  x: { tickFormat: (x) => d3.format("0.2s")(x).replace("G", "B") },
  y: { tickFormat: (x) => d3.format("0.1s")(x).replace("G", "B") },
  marks: [
    Plot.dot(
      d3
        .range(100)
        .map(() => [10 ** 10 * Math.random(), 10 ** 10 * Math.random()])
    )
  ]
})
3 Likes

Thank you so much Professor! This worked! <3

1 Like