I am drawing barchart for discrete data and ggplot by default adjust the y-axis for me, but gives me y-axis label with breaks at 0.5 interval which I don't like it. I tried scale_y_discrete
but y-axis breaks is given for every discrete value, which is not good also.
Can I force the y-axis break to be composed of integer only, and give proper breaks for each of the facet?
Sample script is as below:
set.seed(1)
chart.data <- data.frame(x=rep(LETTERS[1:10],3),
y=c(sample(0:10,10,replace=TRUE),
sample(0:100,10,replace=TRUE),
sample(0:1000,10,replace=TRUE)),
group=sort(rep(1:3,10)))
chart <- ggplot(data=chart.data,aes(x=x,y=y))
chart <- chart + geom_bar(stat="identity")
chart <- chart + scale_y_discrete()
chart <- chart + facet_wrap(facets=~group,nrow=1,scale="free_y")
Update #1
Since the post is being considered as possible duplicate, the script is refined to show a more complicated scenario.