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.

2 comments:

Unknown said...

Very Impressive Python tutorial. The content seems to be pretty exhaustive and excellent and will definitely help in learning Python. I'm also a learner taken up Python training and I think your content has cleared some concepts of mine. While browsing for Python tutorials on YouTube i found this fantastic video on Python. Do check it out if you are interested to know more.:-https://www.youtube.com/watch?v=HcsvDObzW2U

sangeetha sathyan said...

One of the great article, I have seen yet. Waiting for more updates.
ccna Training in Chennai
ccna course in Chennai
R Programming Training in Chennai
Python Classes in Chennai
Best Python Training in Chennai
CCNA Training in Anna Nagar
CCNA Training in Porur