1

I'm using the PDF device in R and I would like if possible to incorporate some characters from the zapf dingbats font in my legend lables (specifically the large open and filled circles for cloud situations of overcast and clear sky).

I found the extrafont package https://cran.r-project.org/web/packages/extrafont/extrafont.pdf but that seems to change the overall font. I also know how to use expression for greek and math symbols, but that doesn't seem to include these symbols.

I attach a plot that I made with NCL to show the kind of lable I am trying to recreate in my R script. enter image description here

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86

1 Answers1

1

You just specify the appropriate Unicode value.

plot(iris[,3:4])
legend("topleft", legend=c("\U2600", "\U2601", "\U2602", "\U2603"))

Unicode Legend

G5W
  • 36,531
  • 10
  • 47
  • 80
  • Thanks, that works for the device type of PNG, but when I use the device type PDF("network.pdf", width = 8, height = 6 ) I get the error: In text.default(x, y, labels = labels, col = label.color, ... : font metrics unknown for Unicode character U+2600. Adding pdf.options(encoding='ISOLatin2.enc') didn't help, but I presume I need something similar to enable this font encoding with PDF? – ClimateUnboxed Sep 13 '17 at 15:52
  • Got it - I needed to do this: cairo_pdf("network.pdf", width = 8, height = 6,family="Arial Unicode MS" ) which I found here: https://stackoverflow.com/questions/6615161/how-do-i-write-a-plot-containing-a-symbol-to-pdf-in-r – ClimateUnboxed Sep 13 '17 at 15:56