You can use expand_limits
ggplot(mtcars, aes(wt, mpg)) + geom_point() + expand_limits(y=0)
Here is a comparison of the two:
As of version 1.0.0 of ggplot2
, you can specify only one limit and have the other be as it would be normally determined by setting that second limit to NA
. This approach will allow for both expansion and truncation of the axis range.
ggplot(mtcars, aes(wt, mpg)) + geom_point() +
scale_y_continuous(limits = c(0, NA))
specifying it via ylim(c(0, NA))
gives an identical figure.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…