這可能是重複的,但我找不到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