Monday, March 11, 2013

Smooth lines become jagged when saved from matplotlib

I just learned about a very important parameter when saving .pdf or .svg files of figures with many small axes:

import matplotlib.pyplot as plt
plt.rc('path',simplify=False)
or...
plt.rc('path',simplify_threshold=.0001)

Matplotlib (pyplot) tries to intelligently downsample the points that make up lines in order to save space, but when you have very small subplots this results in jagged lines. By either turning off this path.simplify feature, or decreasing the threshold, those lines will be smoother.

No comments: