Skip to content

Instantly share code, notes, and snippets.

@breezewish
Created June 5, 2017 07:12
Show Gist options
  • Save breezewish/3e7a79661d531ae120bb4243d1b27436 to your computer and use it in GitHub Desktop.
Save breezewish/3e7a79661d531ae120bb4243d1b27436 to your computer and use it in GitHub Desktop.
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