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

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