Best way to insert high quality figures in MS Word

The neverending battle of Word vs PDF or Eps

With raster images you have to find your compromise between definition and size. If you know that the document will be printed at 600 DPI you can decide to import images with that definition. But if tomorrow you will have an higher definition printer you should start again. If you increase the DPI your document will increase the size and you will require more resources to your system.

If you can work with a vector image you will not incur in problems related to the image definition, but you can find problems related to the font installed, or you can have a bigger file in case, for example, you plot 1 billion data...

When you have to import inside word a file you can:

  • Go to the source: you can substitute or add the format (and eventually the size) required directly in the script that generated the plot. Read from the matplotlib site [1]. It's better if you can save in a Vector Graphics format [1b].

    plt.savefig(pp, format='pdf') 
    plt.savefig(pp, format='png')
    plt.savefig(pp, format='svg')
    

    or even

    fig.savefig('test.pdf')
    fig.savefig('test.png')
    
  • Use imagemagick [2] or Inkscape [2b] or gimp [2b] to convert a pdf in a png (or in other raster formats, tiff,jpg...) or in a svg (or in others vector graphic format).

    This depends if it is a PDF with vector graphic[3] inside or not.
    In the first case you should find some rare rendering or font problems but no definition problems.
    In the latter case you have to choose a density and the dimensions for the final image.
    Read something more for example on this answer [4].
    You will finish to write something similar to:

    convert file.pdf file.svg                                  # If pdf with vector
    convert -density 600 file.pdf -resize 4961x7016 mypic.png  # With fixed grid
    

Note
If the PDF file was created with a Raster images with a specific definition, e.g. 300 DPI, you will not have so much success with any program increasing the DPI to 400 or 600... :-)
As thumb rule (it usually works) you can assume that in a raster pdf there is the string /image.
So under Linux for example you can run grep and count the occurrences of that string:

grep  -c -i "/image" *pdf
MyRasterPdf.pdf:3    # > 0  if raster pdf
MyVectorPdf.pdf:0    # = 0  if vector pdf

Last but not least, consider LaTex, maybe with a GUI as texmaker.


As of May 2018, Microsoft Word in the Office 365 edition has made two changes which alters the answer to this question:

  • EPS is no longer supported
  • SVG is now supported

This means that the best way to handle high quality graphics is to create a figure in Matplotlib which has the correct size (using plt.figure(figsize=(width_in_inches, height_in_inches)), then to export the figure with plt.savefig('filename.svg'). You can insert this file directly into Word and it will be correctly rendered, even when converting to PDF.

This video shows the whole process and compares formats.


In Word 2016, my workflow for importing matplotlib graphics has been:

import matplotlib.pyplot as plt

Export editable text so that I can adjust figures and text in Illustrator, by default matplotlib exports “Type 3 fonts” which Adobe Illustrator doesn’t understand, so you need to export Type 2/TrueType fonts.

plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42 

save figure

plt.savefig('my_figure.pdf',bbox_inches='tight',transparent = True)

Open in Illustrator and adjust as needed

Export image as .emf

Insert my_figure.emf into Word