这可能是重复的,但我找不到Google
或Stack Overflow
上的Questions that may already have your answer
功能的类似帖子。使用R创建清晰或清晰的图形以导入到PowerPoint中
我不确定用R
创建清晰或锐利图形的最佳方法,然后可以将其导入到例如PowerPoint
中。
以下是创建PDF
文件的代码。当输入PowerPoint
时,生成的图像非常模糊,质量很差。
下一页我使用Cairo
包显示创建漂亮清晰图像的代码和说明。但是,这涉及将结果文件导入名为Inkscape
的第三方软件,并在将文件导入PowerPoint
之前将文件保存为新格式。
有没有一种方法可以创建漂亮清晰的图形,而不涉及将文件导入第三方软件的中间步骤?
谢谢你的任何建议。对不起,如果这是重复的。下面是代码:
setwd('c:/users/markm/simple R programs/')
a <- seq(1,20)
b <- a^0.25
plot(a, b, bty = "l")
pdf("example_pdf_plot_Oct5_2015.pdf")
plot(a, b, bty = "l")
title('Example PDF Plot')
dev.off()
#
# After creating the file below with the Cairo package:
#
# 1. Install the free software 'Inkscape'
# 2. Open the *.svg file with Inkscape and save as a *.emf file.
# 2b. Click 'OK' when asked to convert texts to paths.
# 2c. Click 'Close without saving'
# 3. Import the *.emf file into PowerPoint as a picture.
# 4. Resize and position image in PowerPoint to taste.
#
# install.packages('Cairo')
library(Cairo)
CairoSVG('example_svg_plot_Oct5_2015.svg', onefile = TRUE, pointsize = 12, width=8, height=6, bg="white")
plot(a, b, bty = "l")
title('Example SVG Plot')
dev.off()
如果你建立R中降价的[R脚本,你可以在knitr选项中设置'fig.retina = 2',它会做所有的点大小(等)为你加工。如果您将代码块命名得很好,您也可以获得很好的文件名。 – hrbrmstr
@hrbrmstr我不熟悉'R Markdown'。这是一个类似'R Studio'的GUI吗?也许它是'R Studio'的一部分? –
https://cran.rstudio.com/web/packages/rmarkdown/index.html – hrbrmstr