Creating publication-quality plots for use in Microsoft Word

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating publication-quality plots for use in Microsoft Word

dadrivr
Hi everyone,

I am trying to make some publication-quality plots for use in Microsoft Word, but I am having trouble creating high-quality plots that are supported by Microsoft Word.

If I use the R plot function to create the figure, the lines are jagged, and the picture is not of high quality (same with JPEG(), TIFF(), and PNG() functions).  I have tried using the Cairo package, but it distorts my dashed lines, and the win.metafile results in a picture of terrible quality.  The only way I have succeeded in getting a high quality picture in a file is by using the pdf() function to save the plot as a pdf file, but all my attempts to convert the image in the pdf file to a TIFF or other file type accepted by Word result in considerably degraded quality.  Do you have any suggestions for creating publication-quality plots in R that can be placed in Word documents?  What packages, functions (along with options), and/or conversions would you use?  Thanks so much for your help!
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Bryan Hanson
There's many ways to solve this, but you are close to one already:  Make the
pdf, put the cursor where you want it in the document, then on the menu bar
Insert --> Picture --> From File... And navigate to the file.  This works on
the Mac, and seems to store the picture internally in a different way that
selecting the graphic in a viewer and cutting and pasting.  Quality is
top-notch and the graphic is clickable to be resized (and retains it's
quality).

HTH.  Bryan
*************
Bryan Hanson
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA



On 9/15/10 10:38 AM, "dadrivr" <[hidden email]> wrote:

>
> Hi everyone,
>
> I am trying to make some publication-quality plots for use in Microsoft
> Word, but I am having trouble creating high-quality plots that are supported
> by Microsoft Word.
>
> If I use the R plot function to create the figure, the lines are jagged, and
> the picture is not of high quality (same with JPEG(), TIFF(), and PNG()
> functions).  I have tried using the Cairo package, but it distorts my dashed
> lines, and the win.metafile results in a picture of terrible quality.  The
> only way I have succeeded in getting a high quality picture in a file is by
> using the pdf() function to save the plot as a pdf file, but all my attempts
> to convert the image in the pdf file to a TIFF or other file type accepted
> by Word result in considerably degraded quality.  Do you have any
> suggestions for creating publication-quality plots in R that can be placed
> in Word documents?  What packages, functions (along with options), and/or
> conversions would you use?  Thanks so much for your help!

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Gabor Grothendieck
In reply to this post by dadrivr
On Wed, Sep 15, 2010 at 10:38 AM, dadrivr <[hidden email]> wrote:

>
> Hi everyone,
>
> I am trying to make some publication-quality plots for use in Microsoft
> Word, but I am having trouble creating high-quality plots that are supported
> by Microsoft Word.
>
> If I use the R plot function to create the figure, the lines are jagged, and
> the picture is not of high quality (same with JPEG(), TIFF(), and PNG()
> functions).  I have tried using the Cairo package, but it distorts my dashed
> lines, and the win.metafile results in a picture of terrible quality.  The
> only way I have succeeded in getting a high quality picture in a file is by
> using the pdf() function to save the plot as a pdf file, but all my attempts
> to convert the image in the pdf file to a TIFF or other file type accepted
> by Word result in considerably degraded quality.  Do you have any
> suggestions for creating publication-quality plots in R that can be placed
> in Word documents?  What packages, functions (along with options), and/or
> conversions would you use?  Thanks so much for your help!


Those are all bitmapped formats. For best quality you want a
vector-based format. This link here discusses the difference:
http://web.archive.org/web/20070221152152/http://www.stc-saz.org/resources/0203_graphics.pdf

Microsoft's metafile formats are vector formats that work well in
Word.  Try savePlot with type = "wmf" or type = "emf" as the argument
or right click a graphic in R and choose one of the metafile options.


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Marc Schwartz-3
In reply to this post by Bryan Hanson
That approach will be unique to OSX, upon which PDF is a default format. You can copy and paste from a PDF document using Preview into Office or iWork or similar apps. However, when subsequently displaying that content on a non-OSX system, the content will be shown as a bitmap not as the vector based PDF. You would have to save the new document to a new PDF file via the printer dialogs, in order to retain the full high quality PDF content.

The ultimate question for the OP is what do you intend to do with the Word document relative to displaying/printing the content in the Word document?

Using EMF/WMF is one way to get vector based images from R into other Windows apps and typically that provides suitable quality.

However, if you truly want "publication quality", then you would need to use encapsulated postscript (EPS) for which you can see ?postscript and pay attention to the Details section for proper creation.

However, after importing an EPS image into Word on Windows, you will not see the EPS based image, but a bitmapped preview. You would then have to print the document to a PS compatible printer to see the vector based content in the imported image in the output.

So it all depends upon how you plan to use the document.

HTH,

Marc Schwartz

On Sep 15, 2010, at 9:50 AM, Bryan Hanson wrote:

> There's many ways to solve this, but you are close to one already:  Make the
> pdf, put the cursor where you want it in the document, then on the menu bar
> Insert --> Picture --> From File... And navigate to the file.  This works on
> the Mac, and seems to store the picture internally in a different way that
> selecting the graphic in a viewer and cutting and pasting.  Quality is
> top-notch and the graphic is clickable to be resized (and retains it's
> quality).
>
> HTH.  Bryan
> *************
>
> On 9/15/10 10:38 AM, "dadrivr" <[hidden email]> wrote:
>
>>
>> Hi everyone,
>>
>> I am trying to make some publication-quality plots for use in Microsoft
>> Word, but I am having trouble creating high-quality plots that are supported
>> by Microsoft Word.
>>
>> If I use the R plot function to create the figure, the lines are jagged, and
>> the picture is not of high quality (same with JPEG(), TIFF(), and PNG()
>> functions).  I have tried using the Cairo package, but it distorts my dashed
>> lines, and the win.metafile results in a picture of terrible quality.  The
>> only way I have succeeded in getting a high quality picture in a file is by
>> using the pdf() function to save the plot as a pdf file, but all my attempts
>> to convert the image in the pdf file to a TIFF or other file type accepted
>> by Word result in considerably degraded quality.  Do you have any
>> suggestions for creating publication-quality plots in R that can be placed
>> in Word documents?  What packages, functions (along with options), and/or
>> conversions would you use?  Thanks so much for your help!
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

dadrivr
In reply to this post by Bryan Hanson
Thanks for your help, guys.  I'm looking to produce a high-quality plot (no jagged lines or other distortions) with a filetype that is accepted by Microsoft Word on a PC and that most journals will accept.  That's why I'd prefer to stick with JPEG, TIFF, PNG, or the like.  I'm not sure EPS would fly.

I tried inserting the PDF directly into Word, but I am on a PC and there is a loss of quality in the transfer.  I'm not sure I know how to use the approach that Marc suggested in reference to saving a new PDF for use in Word.

I also tried Gabor's suggestion to save in Microsoft's metafile format (savePlot with type = wmf and emf), but the images contain lines that are as jagged as those created from the regular R plot output.

Is there a way to enable anti-aliasing on all regular R plot output to clean up the jaggies and then save it in another format?  Or should I try something else?  Thanks again!

Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Gabor Grothendieck
On Wed, Sep 15, 2010 at 11:25 AM, dadrivr <[hidden email]> wrote:

>
> Thanks for your help, guys.  I'm looking to produce a high-quality plot (no
> jagged lines or other distortions) with a filetype that is accepted by
> Microsoft Word on a PC and that most journals will accept.  That's why I'd
> prefer to stick with JPEG, TIFF, PNG, or the like.  I'm not sure EPS would
> fly.
>
> I tried inserting the PDF directly into Word, but I am on a PC and there is
> a loss of quality in the transfer.  I'm not sure I know how to use the
> approach that Marc suggested in reference to saving a new PDF for use in
> Word.
>
> I also tried Gabor's suggestion to save in Microsoft's metafile format
> (savePlot with type = wmf and emf), but the images contain lines that are as
> jagged as those created from the regular R plot output.

You may simply be viewing the document at such a small resolution that
the resolution is not there to display smooth lines regardless of the
approach.  Try viewing the document at increased zoom.  With vector
based images they automatically adapt to the resolution available.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Marc Schwartz-3
In reply to this post by dadrivr
On Sep 15, 2010, at 10:25 AM, dadrivr wrote:

>
> Thanks for your help, guys.  I'm looking to produce a high-quality plot (no
> jagged lines or other distortions) with a filetype that is accepted by
> Microsoft Word on a PC and that most journals will accept.  That's why I'd
> prefer to stick with JPEG, TIFF, PNG, or the like.  I'm not sure EPS would
> fly.
>
> I tried inserting the PDF directly into Word, but I am on a PC and there is
> a loss of quality in the transfer.  I'm not sure I know how to use the
> approach that Marc suggested in reference to saving a new PDF for use in
> Word.
>
> I also tried Gabor's suggestion to save in Microsoft's metafile format
> (savePlot with type = wmf and emf), but the images contain lines that are as
> jagged as those created from the regular R plot output.
>
> Is there a way to enable anti-aliasing on all regular R plot output to clean
> up the jaggies and then save it in another format?  Or should I try
> something else?  Thanks again!


The comments that I had vis-a-vis saving to PDF were specific to operating on an OSX platform. They won't apply to Windows/Linux.

The issue is that the notion of "most journals" is problematic. Many journals will have requirements for specific formats, including plot/graphic output, which I would note includes the use of LaTeX/EPS/PDF as the source content, not Word or similar word processing formats.

If you need to stick with bitmapped formats, then you need to generate the plot file with a specific size/dpi in mind, so that the content will not be resized during editing. It is the resizing of plots and images that gets you into trouble with bitmapped formats, resulting in the oft seen "pixelation".

I would recommend that you check specifically with the journal(s) that you are targeting to find out exactly what they want. They typically publish guidelines for authors, which you should seek out.

Once you know exactly what the specific journals require, then you can target the content creation accordingly.

You can also search the archives via rseek.org (using "publication quality plots") to review past discussions on this same topic.

HTH,

Marc

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Thomas Lumley
In reply to this post by dadrivr
On Wed, 15 Sep 2010, dadrivr wrote:

>
> Thanks for your help, guys.  I'm looking to produce a high-quality plot (no
> jagged lines or other distortions) with a filetype that is accepted by
> Microsoft Word on a PC and that most journals will accept.  That's why I'd
> prefer to stick with JPEG, TIFF, PNG, or the like.  I'm not sure EPS would
> fly.

One simple approach, which I use when I have to create graphics for MS Office while on a non-Windows platform is to use PNG and set the resolution and file size large enough.  At 300dpi or so the physics of ink on paper does all the antialiasing you need.

Work out how big you want the graph to be, and use PNG with enough pixels to get at least 300dpi at that final size. You'll need to set the pointsize argument and it will help to set the resolution argument.

      -thomas

Thomas Lumley
Professor of Biostatistics
University of Washington, Seattle

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Mxkuhn
You might want to check out the Reproducible Research task view:

   http://cran.r-project.org/web/views/ReproducibleResearch.html

There is a section on Microsoft formats, as well as other formats that
can be converted.

Max



On Wed, Sep 15, 2010 at 11:49 AM, Thomas Lumley
<[hidden email]> wrote:

> On Wed, 15 Sep 2010, dadrivr wrote:
>
>>
>> Thanks for your help, guys.  I'm looking to produce a high-quality plot
>> (no
>> jagged lines or other distortions) with a filetype that is accepted by
>> Microsoft Word on a PC and that most journals will accept.  That's why I'd
>> prefer to stick with JPEG, TIFF, PNG, or the like.  I'm not sure EPS would
>> fly.
>
> One simple approach, which I use when I have to create graphics for MS
> Office while on a non-Windows platform is to use PNG and set the resolution
> and file size large enough.  At 300dpi or so the physics of ink on paper
> does all the antialiasing you need.
>
> Work out how big you want the graph to be, and use PNG with enough pixels to
> get at least 300dpi at that final size. You'll need to set the pointsize
> argument and it will help to set the resolution argument.
>
>     -thomas
>
> Thomas Lumley
> Professor of Biostatistics
> University of Washington, Seattle
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



--

Max

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Mark Difford
In reply to this post by dadrivr
>> I'd prefer to stick with JPEG, TIFF, PNG, or the like.  I'm not sure EPS would fly.

Preferring to stick with bitmap formats (like JPEG, TIFF, PNG) is likely to give you the jagged lines and other distortions you profess to want to avoid.

EPS (encapsulated postscript, which handles vector+bitmap) is one of the graphic file formats preferred by most quality journals. Surprisingly, not too many people seem to be aware of the fact that PDF "really" is a crippled form of postscript.

Regards,
Mark.


Mark Difford (Ph.D.)
Research Associate
Botany Department
Nelson Mandela Metropolitan University
Port Elizabeth, South Africa
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Abhijit Dasgupta, PhD-2
In reply to this post by dadrivr
  On 9/15/10 10:38 AM, dadrivr wrote:

> Hi everyone,
>
> I am trying to make some publication-quality plots for use in Microsoft
> Word, but I am having trouble creating high-quality plots that are supported
> by Microsoft Word.
>
> If I use the R plot function to create the figure, the lines are jagged, and
> the picture is not of high quality (same with JPEG(), TIFF(), and PNG()
> functions).  I have tried using the Cairo package, but it distorts my dashed
> lines, and the win.metafile results in a picture of terrible quality.  The
> only way I have succeeded in getting a high quality picture in a file is by
> using the pdf() function to save the plot as a pdf file, but all my attempts
> to convert the image in the pdf file to a TIFF or other file type accepted
> by Word result in considerably degraded quality.  Do you have any
> suggestions for creating publication-quality plots in R that can be placed
> in Word documents?  What packages, functions (along with options), and/or
> conversions would you use?  Thanks so much for your help!
Another option I've used is to export to PDF (which seems to give the
best quality) and then use the (free) Imagemagick program to convert the
PDF to high-resolution PNG. This worked for some involved heatmaps that
were submitted to a journal. Imagemagick can be downloaded directly for
Windows or via Cygwin.

Suppose your figure is in fig1.pdf. You can use the following command
(once Imagemagick is downloaded and in your path):

system("convert -density 300x300 fig1.pdf fig1.png")



--

Abhijit Dasgupta, PhD
Director and Principal Statistician
ARAASTAT
Ph: 301.385.3067
E: [hidden email]
W: http://www.araastat.com

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

Gavin Simpson
In reply to this post by dadrivr
On Wed, 2010-09-15 at 08:25 -0700, dadrivr wrote:
> Thanks for your help, guys.  I'm looking to produce a high-quality plot (no
> jagged lines or other distortions) with a filetype that is accepted by
> Microsoft Word on a PC and that most journals will accept.  That's why I'd
> prefer to stick with JPEG, TIFF, PNG, or the like.  I'm not sure EPS would
> fly.

>From my experience, most (all of the ones I have personal experience
with) of the large publishers of scientific journals accept EPS as a
file format. I have used it [EPS] routinely for providing figures to
Windows-bound colleagues to insert into Word.

EPS is perfectly acceptable in Word on a PC. The only proviso is that,
as has been mentioned, Word will only *display* a low resolution bitmap
"preview" of EPS image *in* the document on screen whilst editing. When
printed to a postscript printer or converted to PDF via something like
Distiller or via publishers' online submission tools, the figure will be
in the best possible quality.

TIFF is the only bitmap format I am aware of that journals routinely
accept.

So, IMHO, EPS or TIFF are the only two viable options if you factor in
wide journal acceptance.

> I tried inserting the PDF directly into Word, but I am on a PC and there is
> a loss of quality in the transfer.  I'm not sure I know how to use the
> approach that Marc suggested in reference to saving a new PDF for use in
> Word.

I haven't used the recent version of Word, but PDF was not accepted as
an "picture" format, on a PC (Macs may be different).

> I also tried Gabor's suggestion to save in Microsoft's metafile format
> (savePlot with type = wmf and emf), but the images contain lines that are as
> jagged as those created from the regular R plot output.

On screen or when printed? I wouldn't expect them to be jagged when
printed for the same reasons as EPS; they are a vector format.

> Is there a way to enable anti-aliasing on all regular R plot output to clean
> up the jaggies and then save it in another format?  Or should I try
> something else?  Thanks again!

Use EPS, or as Thomas Lumley (IIRC) suggested, a high resolution (300dpi
or greater) TIFF.

Also, make sure you are plotting on the device directly, e.g.

postscript(....)
plot(....)
dev.off()

rather than use the menu options to save plots/copy to clipboard
features in the windows version of R. I've not used that version for
some time, but you get far more control over the parameters of the
produced plot (height, width, paper etc) by plotting directly on the
device.

HTH

G

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Creating publication-quality plots for use in Microsoft Word

dadrivr
Thanks for all the suggestions, guys.  It looks like TIFF may be the easiest solution, as I wouldn't have to worry about printing to a postscript printer or converting to PDF (when using EPS).  That way, I could send the Word file as is to all coauthors (important for collaboration - i.e., track changes) and submit the same file to journals without the need for any secondary conversion.  Thanks, everyone.