Search code examples
rggplot2legend-properties

ggplot labels unit format


Hey i want to change the unit format

and this my code for y scales

scale_y_continuous(labels = scales::unit_format(unit="Rp"))

and the output will be 400 000 Rp

but, i want the output to be like this, Rp 400 000

scale_x_continuous(labels = math_format(x^2)),

it give error message, i want the output like this, enter image description here


Solution

  • for y scales, use prefix

    scale_y_continuous(labels = scales::unit_format(prefix ="Rp ", unit = ""))
    

    for x, dont forget a .

    scale_x_continuous(labels = scales::math_format(expr = .x^2))