Add Dollar Signs to Axis

I want to add dollar signs to the x and y-axis (e.g., $10K). I’m sure I am missing something simple.

Thank you for any help!!!

using Gadfly, Printf
plot(x=rand(10)*10_000, y=rand(10)*10_000,
Scale.x_continuous(labels=x → @sprintf(“% dk”, x/1000)),
Scale.y_continuous(labels=x → @sprintf(“% dk”, x/1000)))

1 Like

Try escaping the dollar sign with a backslash like this:

using Gadfly, Printf
plot(x=rand(10)*10_000, y=rand(10)*10_000,
       Scale.x_continuous(labels=x -> @sprintf("\$% dk", x/1000)),
       Scale.y_continuous(labels=x -> @sprintf("\$% dk", x/1000)))

Which for me produces:

The backslash is to prevent Julia to interpret the dollar sign as interpolation of another string.

1 Like