How to get high resolution R plot into Microsoft Word documents

时间:2018-02-26 17:57:35

标签: r plot

I'm using a macbook (version 10.11.6) and RStudio (Version 1.1.423 – © 2009-2018 RStudio, Inc.).

Whenever I use the plot function in RStudio, I get high quality graphics, but when I copy and paste or import the graphic into Microsoft Word 11, the graphic is no longer high quality. It looks awful. I can barely see the legend contents. Is there a way to export high quality graphics into Microsoft Word without losing the resolution?

sample code:

dose<- c(20, 30, 40, 45, 60)
drugA <- c(16, 20, 27, 40, 60)
par(family="serif")
plot(dose, drugA, type="b", lty=1, col=578)
legend(40, 20, c("random 0.865", 
                 "Random2  0.943"), 
       lty = c(1,3), col = c(578,84), 
       bty="o", cex=.50)

Edit: (I know how to increase plot resolution in R--I need to maintain the resolution when exporting into Microsoft Word)

This is a Microsoft Word 11 issue, but I'm leaving this question up because I initially thought it was an RStudio issue. Others might have the same question.

1 个答案:

答案 0 :(得分:0)

实现这一目标的最简单方法是将其保存为pdf(或其他矢量文件,如svg),如下所示:

dose<- c(20, 30, 40, 45, 60)
drugA <- c(16, 20, 27, 40, 60)
par(family="serif")
pdf("drug_dose_1.pdf")
plot(dose, drugA, type="b", lty=1, col=578)
legend(40, 20, c("random 0.865", 
                 "Random2  0.943"), 
       lty = c(1,3), col = c(578,84), 
       bty="o", cex=.50)
dev.off()

然后将该文件导入Word。它将保持其质量,因为图形是矢量,而不是图像。