I\'m having a problem with geom_bars wherein the bars are not rendered when I specify limits on the y-axis. I believe the following should reproduce the problem:
Adding an answer for my case which was slightly different in case someone comes across this:
When using position="dodge", the bars get horizontally resized automatically to fill space that is often well beyond the limits of the data itself. As a result, even if both your x-axis and y-axis limits are limits=c(min-1, max+1, for certain data sets, the position="dodge" might resize it beyond that limit range, causing the bars to not appear. This might even occur if your limit floor is 0, unlike the case above.
Using oob=rescale_none in both scale_y_continous() AND scale_x_continuous() fixes this issue by simply cutting off the resizing done by position="dodge".
As per earlier comment, it requires package:scales so run library(scales) first.
Hope this helps someone else where the above answers only get you part way.
This worked for me based on the link shared previously.
p + coord_cartesian(ylim=c(5,15))
You could try, with library(scales):
+ scale_y_continuous(limits=c(2000,2500),oob = rescale_none)
instead, as outlined here.