While making a bar plot with ggplot I run into troubles getting the preferred thousands separator. I would like thousands to be separated by a dot instead of a comma. Like this it gives no separator:
require(ggplot2) require(scales) options(scipen=10) D = data.frame(x=c(1,2),y=c(1000001,500000)) p = ggplot(D,aes(x,y)) + geom_bar(stat="identity") p
and like this it gives a comma:
p + scale_y_continuous(labels=comma)
How do you get a dot as thousands separator? I can't find documentation on which types of other labels exist besides some examples on http://docs.ggplot2.org/0.9.3.1/scale_continuous.html.
Thanks in advance,
Forza
p + scale_y_continuous(labels=function(x) format(x, big.mark = ".", scientific = FALSE))
this also works:
p + scale_y_continuous(labels = scales::comma)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With