<p dir="auto">I get clipping errors when I use <code class="notranslate">fill_between()</code>, set <code class="notranslate">ylim</code> such that not all of the graph is inside the plotting area, and export to PGF.  See code below:</p>
<p dir="auto">Python:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
from matplotlib import pyplot as plt

np.random.seed(3)
n = 100
m = np.random.random(n)
M = m + np.random.random(n)
M[80] = 3
plt.fill_between(np.arange(n), m, M)
plt.ylim(0,2.1)
plt.savefig('test.pgf')"><pre class="notranslate"><code class="notranslate">import numpy as np
from matplotlib import pyplot as plt

np.random.seed(3)
n = 100
m = np.random.random(n)
M = m + np.random.random(n)
M[80] = 3
plt.fill_between(np.arange(n), m, M)
plt.ylim(0,2.1)
plt.savefig('test.pgf')
</code></pre></div>
<p dir="auto">LaTeX:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\input{test.pgf}
\end{document}"><pre class="notranslate"><code class="notranslate">\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\input{test.pgf}
\end{document}
</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/6285646/5503662/017cfed2-877a-11e4-9967-1d87850cc42d.gif"><img src="https://cloud.githubusercontent.com/assets/6285646/5503662/017cfed2-877a-11e4-9967-1d87850cc42d.gif" alt="test" data-animated-image="" style="max-width: 100%;"></a></p>
<p dir="auto">System:<br>
matplotlib: 1.3.1<br>
Python: 2.7.6<br>
numpy: 1.8.2<br>
OS: 64bit Linux (Ubuntu 14.04.1)</p>
<p dir="auto">It appears that when there is a path outside the plotting limits then not all the path coordinates get plotted.  When I run the code below with <code class="notranslate">xmax=1.1</code> versus <code class="notranslate">xmax=1.0</code>, the axvspan is plotted wrong in latex.  Inspection of the pgf file for the two versions of <code class="notranslate">xmax</code> indicates that a <code class="notranslate">\pgfpathlineto</code> command is missing in the <code class="notranslate">xmax=1.1</code> version.  I've traced it to <code class="notranslate">_print_pgf_path()</code> in the backend and the line <code class="notranslate">for points, code in path.iter_segments(transform, clip=clip):</code> which is asking for clipped points.</p>
<p dir="auto">Python Code</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

ax.plot([0,1],[0,1],'-k')
ax.set_xlim(0,1)
ax.axvspan(xmin=0.5, xmax=1.1)

fig.savefig('test.pgf')"><pre class="notranslate"><code class="notranslate">import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

ax.plot([0,1],[0,1],'-k')
ax.set_xlim(0,1)
ax.axvspan(xmin=0.5, xmax=1.1)

fig.savefig('test.pgf')
</code></pre></div>
<p dir="auto">Latex code</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="\documentclass {article}
\usepackage{pgf}

\begin{document}
    \begin{figure}
        \centering
        \input{test.pgf}
    \end{figure}
\end{document"><pre class="notranslate"><code class="notranslate">\documentclass {article}
\usepackage{pgf}

\begin{document}
    \begin{figure}
        \centering
        \input{test.pgf}
    \end{figure}
\end{document
</code></pre></div>
<p dir="auto">Here is a pic of the result after compiled with latex  (pdflatex or xelatex)<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/5891255/4724119/c3d70a78-594d-11e4-95d8-6614baccdf02.png"><img src="https://cloud.githubusercontent.com/assets/5891255/4724119/c3d70a78-594d-11e4-95d8-6614baccdf02.png" alt="untitled" style="max-width: 100%;"></a></p>
<p dir="auto">However, saving to .pdf produces the right result</p>