intToUtf8
尝试使用set将整数转换为 UTF-8 编码的字符向量pch=
。
(.pch <- c(intToUtf8(9675), intToUtf8(9679)))
# [1] "○" "●"
虽然它适用于png
,
png('foo.png', 400, 400)
with(df, plot(x, y, pch=.pch[(z < 0) + 1], xlim=0:1, ylim=0:1))
legend('topleft', pch=.pch, legend=letters[1:2])
dev.off()
它不会pdf
为了
pdf.options(encoding='ISOLatin2.enc')
pdf('foo.pdf', 4, 4)
with(df, plot(x, y, pch=.pch[(z < 0) + 1], xlim=0:1, ylim=0:1))
legend('topleft', pch=.pch, legend=letters[1:2])
dev.off()
但我想要pdf
。
也尝试'ISOLatin1.enc'
过没有效果。
> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Zurich
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.3.1 tools_4.3.1
数据:
df <- structure(list(x = c(0.2, 0.6, 0.7, 0.9), y = c(0.4, 0.7, 0.9,
0.5), z = c(-1, -1, 1, 1)), class = "data.frame", row.names = c(NA,
-4L))