1 min read

Round y-axis decimals in ggplot2

To do so, it is first assumed that the values along y-axis are continuous. Use the scale_y_continuous() function in ggplot expression.

A working example might look like:

  • scale_y_continuous(labels=function(x) sprintf("%.2f", x))

where 2f dictates the number of decimals (two, in this case).