1

I exported eps and emf format figure and opened it in word. The figure is very rough after converting into pdf file (see below Fig.1). If export pdf format figure directly, no such problem (see below Fig.2)

Could anybody help me with this? Thanks!

x=(1:100)
y=x+rnorm(100)*10
postscript("Z:/eps.eps", width = 5, height = 5, horizontal = FALSE,
           onefile = FALSE, paper = "special", colormodel = "cmyk")
plot(x,y,type='l',xlab='',ylab='')
dev.off()


pdf("Z:/pdf.pdf")
plot(x,y,type='l',xlab='',ylab='')
dev.off()
Feng Tian
  • 41
  • 1
  • 3

1 Answers1

2

If you export your plot to Powerpoint using my new export package in native Office vector format, and from there save as PDF you will see that you will retain good quality:

install.packages("export")
library(export)
x=(1:100)
y=x+rnorm(100)*10
plot(x,y,type='l',xlab='',ylab='')
graph2ppt(file="plot.pptx", width=7, height=5)
graph2doc(file="plot.docx", width=7, height=5)

Here is a screen capture of the exported plot in Powerpoint: enter image description here

After exporting to PDF in Powerpoint (File...Save As...PDF...) you will see that it will stay in good quality (vector-based, so you can zoom as much as you like) - here is a zoom on the exported PDF to show this : enter image description here

Note that in the exported Powerpoint you can also right click on Ungroup to make any required small changes to the layout of the plot (export is in Office native DrawingML format).

The recipe above works for base R plots, lattice plots and ggplot2 plots, and the package also allows one to export statistical output to tables in Powerpoint & Word as well...

Tom Wenseleers
  • 7,535
  • 7
  • 63
  • 103
  • Do you know of a way to export vector graphics using Rmarkdown? I have not had any luck there. – Zelazny7 Jul 02 '16 at 19:33
  • Here is a demo, https://support.rstudio.com/hc/en-us/articles/360004672913-Rendering-PowerPoint-Presentations-with-RStudio, but haven't tried it myself. I believe you have to install the latest development version of RStudio & Rmarkdown to do this, but haven't checked the quality of the output... – Tom Wenseleers Nov 04 '18 at 00:26
  • Just released a new package, export, to make this easier though, and it just came out on CRAN... – Tom Wenseleers Nov 04 '18 at 00:27