Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Insert matplotlib charts as vector image to MS Word

Purpose

MS Word 2016 do support svg. But they are rasterized when exporting to PDF currently. Here is a workaround.

Steps

  1. Export as svg

  2. Use inkscape to convert dash into paths

inkscape -g "your_file.svg" --verb=EditSelectAll \
    --verb=SelectionUnGroup --verb=SelectionUnGroup --verb=SelectionUnGroup --verb=SelectionUnGroup --verb=SelectionUnGroup --verb=SelectionUnGroup \
    --verb=com.vaxxine.filter.dashes --verb=FileSave --verb=FileQuit

Note: for complex charts, more SelectionUnGroup might be needed.

  1. Use inkscape to convert svg into EMF
inkscape "your_file.svg" --export-emf="your_file.emf"
  1. Import EMF as image in MS Word
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment