ggplot2 bar plot, no space between bottom of geom and x axis keep space above

The R documentation includes a new convenience function called expansion for the expand argument as the expand_scale() became deprecated as of ggplot2 v3.3.0 release.

ggplot(mtcars) +
  geom_bar(aes(x = factor(carb))) + 
  scale_y_continuous(expand = expansion(mult = c(0, .1)))

I might be missing what you really want, but without using geom_text hack you can still set the limits

ggplot(mtcars, aes(x = as.factor(carb))) + 
    geom_bar() + 
    scale_y_continuous(expand = c(0, 0), limits = c(0, 10.3)) 

# marginally cleaner

Tags:

R

Ggplot2