# ggplot - Make the y axis start at 0

## Problem

We want the bottom of the graph to be 0

data <- data.frame("year"=c(2000, 2005, 2006, 2007), "value"=c(10, 25, 20, 30))
ggplot(data) + geom_col(aes(x=year, y=value))


data is:

> data
year value
1 2000    10
2 2005    25
3 2006    20
4 2007    30


## Solution

Use scale_y_continuous, the function expand_scale inside helps creating the argument to stretch the axis at the bottom and the top. Put 0 at the bottom cuts the chart at 0. We put 0.1 at the top to have a bit of padding.

ggplot(data) + geom_col(aes(x=year, y=value)) +
scale_y_continuous(expand = expand_scale(mult = c(0, 0.1)))


## How can we help?

Whether you already know about your data pain points or just want to have a friendly conversation, send us a message and tell us who you are.