减少R中绘图的pdf文件大小 [英] Reduce pdf file size of plot in R
问题描述
我正在使用以下命令在 R 中绘制一些数据:
i am plotting some data in R using the following commands:
jj = ts(read.table("overlap.txt"))
pdf(file = "plot.pdf")
plot(jj, ylab="", main="")
dev.off()
结果如下:
我遇到的问题是我得到的 pdf 文件很大(25Mb).是减小文件大小的方法吗?JPEG 不是一种选择,因为我需要矢量图形.
The problem I have is that the pdf file that I get is quite big (25Mb). Is the a way to reduce the file size? JPEG is not an option because I need a vector graphic.
推荐答案
看看 tools::compactPDF
- 你需要安装 qpdf 或 ghostscript,但它可以产生巨大的不同到 pdf 文件大小.
Take a look at tools::compactPDF
- you need to have either qpdf or ghostscript installed, but it can make a huge difference to pdf file size.
如果从磁盘读取 PDF 文件,GostScript 质量 (gs_quality
) 有 3 个选项,如 R 帮助文件:
If reading a PDF file from disk, there are 3 options for GostScript quality (gs_quality
), as indicated in the R help file:
打印机
(300dpi)电子书
(150dpi)screen
(72dpi)
printer
(300dpi)ebook
(150dpi)screen
(72dpi)
默认为none
.例如要将文件夹 mypdfs/
中的所有 PDF 转换为 ebook
质量,请使用命令
The default is none
. For example to convert all PDFs in folder mypdfs/
to ebook
quality, use the command
tools::compactPDF('mypdfs/', gs_quality='ebook')
这篇关于减少R中绘图的pdf文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!