Save R-chart with the symbols of Mars and Venus in pdf format

I am trying to save charts that have female (\ u2640) and male (\ u2642) characters. Here is an example of creating a graph using these symbols (I use RStudio):

gender <- rbinom(n=100, size=100, prob=0.5)
plot(gender, cex=2.5,
       pch=ifelse(gender %% 2 == 0, -0x2642L, -0x2640L),
       col=ifelse(gender %% 2 == 0, 2, 3), main="\u2640 and \u2642 Symbols")

It works and generates a graph with these plot symbols . I can save it as an image (PNG), but when I try to save it as a pdf, not all symbols are displayed plot .

This is how I try to save it in pdf format:

pdf("plot.pdf")
gender <- rbinom(n=100, size=100, prob=0.5)
plot(gender, cex=2.5,
       pch=ifelse(gender %% 2 == 0, -0x2642L, -0x2640L),
       col=ifelse(gender %% 2 == 0, 2, 3), main="\u2640 and \u2642 Symbols")

dev.off() 

, CairoPDF. . , . , pdf . pdf.

. :

quartz.save(type = 'pdf', file = 'output.pdf')

. pdf ( "plot.pdf" ), quartz.save(type = 'pdf', file = 'output.pdf')? - ?

.

+4
1

Mac PDF . ( SO.) , "" , " , .

cairo_pdf("Venus_Mars.pdf",family="ArialUnicodeMS")
plot(1,1)
TestUnicode <- function(start="263c", end="2653", ...)
  {
    nstart <- as.hexmode(start)
    nend <- as.hexmode(end)
    r <- nstart:nend
    s <- ceiling(sqrt(length(r)))
    for(i in seq(r)) {
      try(points(.6+(i/10), .8 , pch=-1*r[i],...))
    }
  }
 TestUnicode()
dev.off()
+2

All Articles