Tentando converter números inteiros em vetores de caracteres codificados em UTF-8 usando intToUtf8
to set pch=
.
(.pch <- c(intToUtf8(9675), intToUtf8(9679)))
# [1] "○" "●"
Embora funcione bem para 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()
não será para 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()
mas eu quero pdf
.
Também tentei 'ISOLatin1.enc'
sem sucesso.
> 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
Dados:
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))