Closed lines in matplotlib contour plots
<p>When looking closely at contour plots made with matplotlib, I noticed that smaller contours have inaccurate endpoints which do not close perfectly in PDF figures.  Consider the minimal example:</p>

<pre><code>plt.gca().set_aspect('equal')
x,y = np.meshgrid(np.linspace(-1,1,100), np.linspace(-1,1,100))
r = x*x + y*y
plt.contour(np.log(r))
plt.savefig("test.pdf")
</code></pre>

<p>The central part of the resulting test.pdf file, shown below, clearly shows the problem.  Is there a way to solve this or is it a bug/intrinsic inaccuracy of matploplib?</p>

<p><a href="http://i.stack.imgur.com/NJWKC.png" rel="nofollow"><img src="http://i.stack.imgur.com/NJWKC.png" alt="enter image description here"></a></p>

<p>So I just did the same thing, but got closed contours (see images). Did you check for any updates on the package?</p>

<pre><code>import matplotlib.pyplot as plt
import numpy as np

plt.gca().set_aspect('equal')
x,y = np.meshgrid(np.linspace(-1,1,100), np.linspace(-1,1,100))
r = x*x + y*y
plt.contour(np.log(r))
plt.show()
</code></pre>

<p><a href="http://i.stack.imgur.com/QVrXD.png" rel="nofollow">Zoomed Out</a></p>

<p><a href="http://i.stack.imgur.com/y5P6n.png" rel="nofollow">Zoomed In</a></p>

python pdf matplotlib contour