I have a problem properly displaying fonts in plots generated by ggplot2 in LaTeX reports generated by R studio in Sweave using knitr.
At first I was not able to properly generate pdfs with polish fonts but that problem was tackled in this post:
Unicode Characters in ggplot2 PDF Output
In short, the author adviced using Cairo package (in R) to generate plots using ggplot2.
This worked for me - once -> meaning I was able to generate a plot with polish characters, but when I am trying to use it in sweave document to generate LaTeX report using knitr like this:
<<pieniadze_graph,fig=TRUE,echo=FALSE>>=
library(Cairo)
cairo_pdf("TutorialExercisesPart2-pieniadze_graph.pdf")
plot1 <- qplot(expenditure, data = cas) + xlim(0, 8000) +
xlab(expression(paste("Pieniądze wydane na ucznia ($)"))) +
ylab("Liczba szkółńćźżś")
print(plot1)
@
I get an error.:
Running pdflatex on TutorialExercisesPart2.tex...failed
While investigating while that happend -> i found that the file that cairo is soppoused to generate is blank (there is a pdf file of a name given to cairo_pdf but it can not be opened with pdf viewer -> error cannot open text file)
Now one note is necessary: The cairo_pdf function requires file name to be set. So I give the pdf a name, that is required to be used later by the tex file in a format filename-chunk_name.pdf (So much for dynamic reports :P)
So I am not for the cairo_pdf option. Is there a way to generate proper pdf files without cairo_pdf option?
I was not able to find anything more on this topic without the cairo-pdf...
When I delete the cairo part my tex file is generated nicely with an ugly looking dots labels PDF file in it...