Search code examples
rggplot2labelaxis

Add degree symbol (°) to axis labels in ggplot2


I want to add the degree symbol (°) to the labels on my y-axis (not the axis title). I have a ranking on that axis, with numbers ranging 1-11, and I want each of them to say, for example, "1°" instead of just "1". Is there a way to do that?


Solution

  • My first inclination is to look into expressions and plotmath-like things, but in this case we can simply add the degree symbol to the text.

    library(ggplot2)
    ggplot(mtcars, aes(disp, cyl)) +
      geom_point() +
      scale_y_continuous(labels = ~ paste0(.x, "°"))
    

    ggplot with degree in y-axis labels