Simplest solution: Use Unicode Characters
No expression
or other packages needed.
Not sure if this is a newer feature for ggplot, but it works.
It also makes it easy to mix Greek and regular text (like adding '*' to the ticks)
Just use unicode characters within the text string.
seems to work well for all options I can think of.
Edit: previously it did not work in facet labels. This has apparently been fixed at some point.
library(ggplot2)
ggplot(mtcars,
aes(mpg, disp, color=factor(gear))) +
geom_point() +
labs(title="Title (\u03b1 \u03a9)", # works fine
x= "\u03b1 \u03a9 x-axis title", # works fine
y= "\u03b1 \u03a9 y-axis title", # works fine
color="\u03b1 \u03a9 Groups:") + # works fine
scale_x_continuous(breaks = seq(10, 35, 5),
labels = paste0(seq(10, 35, 5), "\u03a9*")) + # works fine; to label the ticks
ggrepel::geom_text_repel(aes(label = paste(rownames(mtcars), "\u03a9*")), size =3) + # works fine
facet_grid(~paste0(gear, " Gears \u03a9"))
Created on 2019-08-28 by the reprex package (v0.3.0)
expression
function here: https://mcmap.net/q/103868/-getting-latex-into-r-plots – Fourviewports
from a ggplot2. If that can be done, I believe that changing x-tic marks will be straight forward. – Emilieemilinelatex2exp
package: cran.r-project.org/web/packages/latex2exp/vignettes/… – Ozoniferous