The dagger appears in ggplot in the viewer, but is replaced by ... when saved in pdf

I use ggplot2to create a point. One item tag has a dagger (†). The dagger appears in the plot when viewed in RStudio, but it is replaced ... when I save the chart in pdf. Is there a way to prevent the conversion of the graphics device into my dagger ...?

Here is a small example:

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

+4
source share
1 answer

from @BenBolker:

Have a look? pdf, especially the search for "embedded fonts" and "problems with PDF output"

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

Source: https://habr.com/ru/post/1541875/


All Articles