Search code examples
rggplot2x-axis

How to use a greek symbol in grid.arrange()


I am using the grid.arrange() function in R to parse together multiple plots. My current code is structured as follows:

grid.arrange(
plot1,
plot2,
legend,
ncol = 3,
top = "Change in Score",
left = "Change in Score"
)

I am trying to change the left = "Change in Score" to the Greek symbol "Delta" in order to replace "Change in."

No clue how to do this...Thanks for any suggestions!!


Solution

  • I am using the iris dataset as an example. You can use Unicode Characters for in this case Delta \u0394. You can use the following code:

    library(ggplot2)
    plot1 <- ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width)) +geom_point()
    plot2 <- ggplot(iris, aes(x = Petal.Length, y = Petal.Width)) +geom_point()
    
    library(gridExtra)
    library(grid)
    grid.arrange(
      plot1,
      plot2,
      #legend,
      #ncol = 3,
      top = "Change in Score",
      left = "\u0394 Score"
    )
    

    Output:

    enter image description here