I need to save a graph created in ggplot with greek symbols as facet labels.
Here is the code for the graph
library(bayesplot)
library(ggplot2)
df <- data.frame(var1 = rnorm(1e4, 0, 1),
var2 = rnorm(1e4, 6, 4),
var3 = rnorm(1e4, 10, 3))
names(df) <- c("\u03C3", "\u03B4", "\u03BC")
tp <- bayesplot::mcmc_trace(df)
tp
Now this prints to RStudio's plot window just fine...
...with the greek symbols coming up nicely. It also saves nicely to image files. But if I try to save to eps or pdf...
ggplot2::ggsave(filename = "plotMu.eps",
plot = tp,
device = "eps",
dpi = 1200,
width = 15,
height = 10,
units = "cm")
...these greek symbols come up as double dots ..
So how do I get these symbols to show up on the eps/pdf. I have tried saving with encoding and choosing ASCII
but this strategy only works for plotmath expressions and expression()
statements, which doesn't really help my situation as neither of these work for column headings.
I would really appreciate someone outlining step-by-step the process for getting this done. All the explanations online tend to assume some knowledge that I don't have.
device="pdf"
todevice=cairo_pdf
and see if the problem is solved. That is one of the solutions in the @MrFlick possible related link.Error: Unknown graphics device 'cairo_pdf'
. In any case I think I underplayed the importance of the .eps. That's actually the problem that most frustrates me because .eps files are the format journals want their figures in these days. I just included pdf because I was getting the same baffling..
symbols on both .pdf and .eps. I think I will alter the original post to reflect this.