I would like to have pretty labels on the y-axis. For example, I prefer to have 1,000 instead of 1000. How can I perform this in ggplot? Here is a minimum example:
x <- data.frame(a=c("a","b","c","d"), b=c(300,1000,2000,4000))
ggplot(x,aes(x=a, y=b))+
geom_point(size=4)
Thanks for any hint.
With the scales
packages, some formatting options become available: comma, dollar, percent.
See the examples in ?scale_y_continuous
.
I think this does what you want:
library(ggplot2)
library(scales)
x <- data.frame(a=c("a","b","c","d"), b=c(300,1000,2000,4000))
ggplot(x, aes(x = a, y = b)) +
geom_point(size=4) +
scale_y_continuous(labels = comma)