Word – Best way to insert high quality figures in MS Word

matplotlibmicrosoft wordpdf

I need a way to insert hight quality PDF figures into Word without them distorting.

The figures are mostly scientific graphs generated through Python and Matplotlib. The main problem is the text labels in the graphs not rendering properly.

I know you can insert PDF's as objects and EPS files as images, but these figures then display very poorly in Word.

My current workflow is thus to export the figures as PNG files at 300DPI using Inkscape. However, the figure quality is still not satisfactory, and when I increase the DPI there is no apparent increase in quality.

Does someone know of a good way to insert high quality graphs into Word?

Best Answer

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.

Related Question