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'):
continue
print(basename)
with open(basename) as fd:
s = fd.read()
with open(basename, 'w') as fd:
fd.write(s.replace('stroke-miterlimit:100000;', ''))

