0

I built a figure with several plots. This figure must be exported type .pdf that includes some simple characters: "■", "▲" and "●". I'm using ggsave (), which seems very simple to follow.

However, when I export it each of the characters are replaced by other things. I already tried cairo_pdf, without success.

My question is: how can I export the pdf that includes the characters. I have read many blogs and questions without success.

This is my command line:

square <- "■"
triangle <- "▲"
circle<- "●"

p3 <- ggdraw(p2) + draw_label("Sources", x = 0.2, y = 0.09, size = 16,fontface = "bold") +
  
  draw_label("Leaf litter", x = 0.3, y = 0.09, size = 16,fontface = "plain") +
  draw_label(square, x = 0.27, y = 0.092, size = 30,fontface = "bold", color = "coral4",
             fontfamily = "Tahoma") +

    draw_label("Biofilm", x = 0.4, y = 0.09, size = 16,fontface = "plain") +
  draw_label(triangle, x = 0.37, y = 0.092, size = 30,fontface = "bold", color = "turquoise3",
             fontfamily = "Tahoma") +
  
  draw_label("Algae", x = 0.5, y = 0.09, size = 16,fontface = "plain") +
    draw_label(circle, x = 0.47, y = 0.092, size = 30,fontface = "bold", color = "greenyellow",
               fontfamily = "Tahoma") 
p3

p3 + ggsave("Figure_2C.pdf", width=11, height=6.5,  dpi = 600)

Here is the figure with the wrong characters.

enter image description here

Thanks in advance.

Kirds
  • 83
  • 5
  • Hi Pablo, can you provide a reprex? (https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). It will increase the likelihood of getting good answers more quickly. More specifically, if you try to plot only a single plot and export to pdf, does it work or is it only a cowplot issue? Have you tried changing the "Graphics Device" option in Tools > Global Options > General > Graphics? – Marcelo Avila Jun 19 '21 at 22:33

0 Answers0