[R] ISO recommendations for plot output format from R to MS Word

Donald Macnaughton donm@c @end|ng |rom m@t@t@t@com
Fri Feb 19 21:18:50 CET 2021

The native graphics format in Microsoft Office (including Word) is EMF
(Enhanced MetaFile), which is an enhanced version of WMF (Windows MetaFile).
This is a VECTOR format with embedded scalable fonts, so it scales perfectly
to all sizes. R will output EMF graph files using Philip Johnson's
library(devEMF), which is on CRAN. These files can be imported into Word
using Insert > Pictures > ....

These images are "perfect" if the Word document is converted (by Word
itself) to PDF, with unbitmapped fonts and lines, so they look perfect even
if you zoom the PDF to 600%.

I haven't tried lately, but in the past the driver generated huge files from
ggplot2, but small files from the graphics and grid packages.

Don Macnaughton

-----Original Message-----
From: R-help <r-help-bounces using r-project.org> On Behalf Of Robert Dodier
Sent: Thursday, February 18, 2021 12:50 PM
To: r-help using r-project.org
Subject: Re: [R] ISO recommendations for plot output format from R to MS

Hi, a quick follow-up about the question about putting R-generated figures
into MS Word.

I have found by experimenting with some figures and documents that if I
import an SVG figure generated by svglite (didn't try other output
functions), I can view it okay in my installation of MS Word (Word for Mac
16.16.10), and it looks okay in MS Word for Windows (circa 2016 or
2018) on a laptop I have, and two other people can view it okay (one on Mac
and one on Windows). So that seems safe enough to go ahead.

I am informed that MS Word is actually storing a bitmap image of the SVG
figure, which is displayed by non-SVG-aware versions of Word. So that seems
like a good safeguard.

For the record, I converted the SVG to EPS, PNG, PDF, WMF, and EMF via
Imagemagick. EPS and PNG were tolerable, PDF was too fuzzy, and WMF and EMF,
at least as generated, could not be displayed (I was a little surprised by
that). There are, no doubt, many unanswered questions here, which
unfortunately I cannot take the time to explore right now.

In summary I found that importing SVG generated by svglite into MS Word for
Mac seems to work okay to generate a generally-readable file.
Perhaps this experience is useful in some way to others.


Robert Dodier

R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list