当我在R界面中打印ggplot时,某些unicode符号可以工作,而当我将其打印为pdf时,则可以使用其他unicode符号。我想了解这个过程。例如:
library(tidyverse)
library(magrittr)
library(showtext)
d1 <- data.frame(
yvar = letters[1:3] %>%
rep(each = 4),
xvar = LETTERS[1:4] %>%
rep(times = 3),
ev = sample(1:4, size = 12, replace = T)
) %>%
tbl_df %>%
modify(factor)
p1 <- d1 %>%
ggplot(
aes(xvar, yvar, shape = ev)
) +
geom_point(size = 8) +
scale_shape_manual(values=c("\u25BA","\u25D0","\u25BC","\u25B2"))
p1
打印
如果我以pdf格式打印图,启用Open Sans字体后,我会看到
showtext.auto()
ggsave(
"plot 1.pdf",
p1,
width = 4,
height = 2
)
如何在ggplot2
中启用最大数量的unicode符号?
(编辑:我的系统信息)
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252