dagger出现在查看器中的ggplot中,但在保存为pdf时替换为....

时间:2014-05-24 12:23:03

标签: r ggplot2

我正在使用ggplot2创建一个点图。一件商品标签有匕首(†)。当在RStudio中查看时,匕首出现在情节中,但当我将情节保存为pdf时,它将替换为......。有没有办法阻止图形设备将我的匕首转换为......?

这是一个小例子:

library(ggplot2)
# data
  dat <- data.frame(VARIABLES=c("Item 1", "Item 2 †"),
                    est=c(.3, .5),
                    min=c(.2, .4),
                    max=c(.4, .7))
# plot
  ggplot(dat, aes(x=reorder(as.character(VARIABLES), 
                            est), y=est)) +
    geom_pointrange(aes(ymin=min,
                        ymax=max),
                    linetype="dashed") +
    geom_point(size=3) +
    ylim(-1,1) +
    theme_bw() +
    theme(legend.position="none") +
    coord_flip()
#---
# dagger appears in viewer

enter image description here

# save plot
  ggsave(filename="myfig.pdf")
#---
# dagger replaced with ... in pdf

enter image description here

1 个答案:

答案 0 :(得分:6)

来自@BenBolker:

  

参见?pdf,特别是搜索&#34;嵌入字体&#34;和#34; PDF输出问题&#34;

library("Cairo")
ggsave("myfig.pdf", device=cairo_pdf)