将图表导出为带有utf8字符的pdf [英] Export plot as pdf with a utf8 character
问题描述
当我以pdf格式保存图时,标签中的utf8字符不会出现。当我在RStudio中使用导出按钮时,它不会出现,并且当我将此代码包含在带有pdf图形输出的Sweave文档中时,它不会出现。我的问题是用Sweave(不是knitr)得到正确的pdf输出。
(如果我找不到解决方案,我将使用 tikzDevice
来生成它)
<$ p $ (斜体(\\\\\\\\\'),(,phi [0],|,italic(list(x, y)=)))
plot(0,0,ylab = ylab)
编辑
后续问题:自定义图形设备在sweave 显示如何将其集成到自定义图形设备。
< hr>
这似乎是使用 CairoPDF()
frm CairoPDF()
不起作用,那么试试 cairo_pdf()
。
一些sweave代码(使用Rstudio)
\documentclass {article}
\ begin {document}
\SweaveOpts {concord ance = TRUE}
> =
库(Cairo)
CairoPDF(test.pdf)
par(mar = c(6,6,6,6))
ylab < - 表达式(paste(,bar(italic(\\\ℓ)),(,phi [0],|,italic(list(x,y)),)))
plot(0,0,ylab = ylab,cex.lab = 2)
invisible(dev .off())
@
%地块
\includegraphics [width = 6cm] {test.pdf}
\\ \\ end {document}
这是我得到的pdf输出(注意分辨率是垃圾,通过gimp转换成png)
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)
这篇关于将图表导出为带有utf8字符的pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!