Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

How to fix svg figures generated by matplotlib (which are slow in Inkscape)

In recent versions of matplotlib, if you save a figure in .svg format, you will find that the figures are really slow when you open them in Inkscape (and perhaps other graphics programs as well). This is a known issue that has been reported here.

Essentially, the problem is the stroke-miterlimit that matplotlib specifies in the .svg file. Below is a Python script that opens all .svg files in the current working directory, and removes the problematic setting (stroke-miterlimit:100000).

Warning: This scripts modifies the original files without making a backup.

#!/usr/bin/env python3
# coding=utf-8
import os
for basename in os.listdir('.'):
    if not basename.endswith('.svg'):
    with open(basename) as fd:
        s = fd.read()
    with open(basename, 'w') as fd:
        fd.write(s.replace('stroke-miterlimit:100000;', ''))

There's much bigger issues in the world, I know. But I first have to take care of the world I know.

Sign In or Register to comment.