I want to have my x-axis show the scale with an added "m2" at the end of each axis text using the scales::label_number() function. Reproducible code:
tibble(x = 1:10, y = 1:10) |>
ggplot(aes(x, y)) +
scale_x_continuous(label = scales::label_number(suffix = "m^2"))
which gives me "5m^2" (for example) on the x-axis, whereas I want it to show "5m2". It seems the usual suspects of bquote() and expression() do not work with the scales::label_number() function.
>Solution :
Use unicode: "m\u00B2" or the unicode for m^2: "\u33A1"
library(tibble)
library(ggplot2)
tibble(x = 1:10, y = 1:10) |>
ggplot(aes(x, y)) +
scale_x_continuous(label = scales::label_number(suffix = "m\u00B2"))

Created on 2022-05-16 by the reprex package (v2.0.1)