R ggarrange how to include upper scripts in the plot titles?

Viewed 200

I am trying to add plot labels as titles in plots merged by ggarrange. My label contains parantheses and substricpts. I have found that using expression('My volume [m'^3*'/ha]') I can handle both, which works perfectly if placed as x or y label (ylab(expression('My volume [m'^3*'/ha]'))).

However, when using the same approach using ggarrange to combine different plots, and wishing to name them a) and b), the naming prints quotes as well:

enter image description here

How can I correctly write the expression, or using paste('..', '..') approach that quotes are not visible?

Dummy example to create several plots and plot them using ggarrange:

p1 <- ggplot(cars, aes(x=speed, y=dist)) + geom_point() + geom_smooth() 
p2 <- p1
  
ggarrange(p1, p2, 
          nrow = 2, ncol = 1,  
          common.legend = TRUE,
          legend="bottom",
          labels=list(paste("a) ", 'My rate [%]'),
                     paste('b)', expression('My volume [m'^3*'/ha]'))), # How to change this???
          align = c("hv"),
          font.label = list(size = 10, 
                            face = "plain", 
                            color ="black"))

Wrong labeled output b:

enter image description here

1 Answers

Finally, I have found my answer based on this post. This works when replacing titles, but I bet it would work for ggarrange as well. Important it that it works with paranteses and a superscript.

p1 +  ggtitle(expression(paste("a) ", "volume [m"^3, "/ha", "]")))

enter image description here

Related