How can I round number in X-axis on ggplot


Hi @tonpc1611. There are a few ways to do this, so I will provide a few options. A common method is to specify the “breaks” that you want with the scale_x_continuous() function that you can read about here. With your example, this might look like adding this to your existing plot:

+ scale_x_continuous(breaks = c(2008, 2010, 2012, 2014, 2016, 2018, 2020))

Another option is to use number formatting options from the scales package. I have not tested it, but I think this syntax will work:

+ scale_x_continuous(labels = scales::number_format())

I hope this helps!!!