I would like to save specific unicode characters to a pdf file with ggsave
.
Example code
library(ggplot2)
ggplot() +
geom_point(data = data.frame(x=1, y=1), aes(x,y), shape = "\u2191") +
geom_point(data = data.frame(x=2, y=2), aes(x,y), shape = "\u2020")
ggsave("test.pdf", plot = last_plot()), width = 40, height = 40, units = "mm")
However, when saving the .pdf
the unicode characters are transformed to three dots...
Attempts to fix it
cairo_pdf
device in ggsave
-> didn't work.Question
How do I use both unicode characters in a pdf?
> sessionInfo()
R version 3.6.2
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.5
This seems to work on my mac:
library(tidyverse)
quartz(type = 'pdf', file = 'test.pdf')
ggplot() +
geom_point(data = data.frame(x=1, y=1), aes(x,y), shape = "\u2191") +
geom_point(data = data.frame(x=2, y=2), aes(x,y), shape = "\u2020")
Using the suggestion from here: https://stackoverflow.com/a/44548861/1827