I want to make a diagram where in some legend titles I want to introduce some Latex syntax, but the output does not produce the expected result.
As MWE, here is the code I use:
library(ggplot2)
library(latex2exp)
ggplot(data, aes(x = Debt, y = Gini_tra, colour = Gamma_param)) +
geom_line()+
scale_color_discrete(breaks = levels(df_tra$Gamma_param),
labels = c("Redistribution", "Egalitarian Tax", TeX("$\\gamma = 0.76$"), TeX("$\\gamma = 0.9$"), "Flat Tax"))
From this code I was expecting to see γ=0.76
and γ=0.9
, but instead I only see 0.76
and 0.9
.
What I am doing wrong here ?