我正在尝试从PDF导入散点图。该图最初是在R中创建的。导入PDF时,看不到分散点。不确定我在做什么错吗?带线的图似乎可以正常工作。
一个演示该问题的玩具示例:
pdf(file = "./temp.pdf", height = 5, width = 5)
plot(mtcars$mpg, mtcars$cyl, type = "p")
dev.off()
file.show("temp.pdf")
# same issue with ggplot
# pdf(file = "./temp.pdf", height = 5, width = 5)
# ggplot(data = mtcars, mapping = aes(x = mpg, y = cyl)) +
# geom_point()
# dev.off()
p0 <- magick::image_read_pdf('./temp.pdf')
p0
p1 <- pdftools::pdf_render_page('./temp.pdf')
png::writePNG(p1, "temp.png")
file.show("temp.png")
> sessionInfo()
R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.6.0 magrittr_1.5 magick_2.0 tools_3.6.0 Rcpp_1.0.1
[6] pdftools_2.2 qpdf_1.1 png_0.1-7 askpass_1.1
答案 0 :(得分:0)
对于将来遇到这种情况的人,useDingbats = FALSE
函数中的pdf()
为我解决了问题,即
pdf(file = "./temp.pdf", height = 5, width = 5, useDingbats = FALSE)