The utf8 character in the label does not appear when I save the plot in pdf format. It does not appear when I use the "Export" button in RStudio, and it does not appear when I include this code in a Sweave document with pdf graphics output. My problem is to get the correct pdf output with Sweave (not knitr).
(If I don't find a solution, I will generate it with tikzDevice)
ylab <- expression(paste("", bar(italic("\u2113")), "(",phi[0], "|", italic(list(x,y)), ")"))
plot(0,0, ylab=ylab)
EDIT
Follow up question: custom graphical device in sweave shows how to integrate this into a custom graphic device.
This seems to render using CairoPDF() frm the Cairo package using ubuntu14.04, R3.2.1.EDIT from Stephane in the comments: if CairoPDF() doesn't work, then try cairo_pdf().
Some sweave code (using Rstudio)
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<Export_plot, echo=FALSE>>=
library(Cairo)
CairoPDF("test.pdf")
par(mar=c(6,6,6,6))
ylab <- expression(paste("", bar(italic("\u2113")), "(",phi[0], "|", italic(list(x,y)), ")"))
plot(0,0, ylab=ylab, cex.lab=2)
invisible(dev.off())
@
%Plot
\includegraphics[width=6cm]{test.pdf}
\end{document}
This is the pdf output i get (note the resolution is rubbish as i have converted it to png via gimp)
来源:https://stackoverflow.com/questions/31075826/export-plot-as-pdf-with-a-utf8-character