<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>
<p dir="auto">I have a figure that I need to compile using PGF backend because the \Game symbol is incorrect (another issue will be opened for that problem).</p>
<p dir="auto">But when I do, the curves bounding the fill seem to get cropped to the visible window, which breaks the fill, as seen here:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/c30e4c2507eb41d2b9af39c3498e3c1ceff40bd238ba3cff7771d24e8b2215ca/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313835393934372f323337323436312f63616666653862362d613833612d313165332d393661312d3666626332366662646566622e6a7067"><img src="https://camo.githubusercontent.com/c30e4c2507eb41d2b9af39c3498e3c1ceff40bd238ba3cff7771d24e8b2215ca/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313835393934372f323337323436312f63616666653862362d613833612d313165332d393661312d3666626332366662646566622e6a7067" alt="ddlabeled" data-canonical-src="https://f.cloud.github.com/assets/1859947/2372461/caffe8b6-a83a-11e3-96a1-6fbc26fbdefb.jpg" style="max-width: 100%;"></a></p>
<p dir="auto">When using the other backends, this behavior is not seen, for instance,<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/480383bf0f0f2202e4e70e05ca11e9bd2460ff076f6e5a7cf48e5cc8da6e9734/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313835393934372f323337323437352f65366230386637302d613833612d313165332d396561662d3866313365393838363037372e706e67"><img src="https://camo.githubusercontent.com/480383bf0f0f2202e4e70e05ca11e9bd2460ff076f6e5a7cf48e5cc8da6e9734/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313835393934372f323337323437352f65366230386637302d613833612d313165332d396561662d3866313365393838363037372e706e67" alt="ddlabeled" data-canonical-src="https://f.cloud.github.com/assets/1859947/2372475/e6b08f70-a83a-11e3-9eaf-8f13e9886077.png" style="max-width: 100%;"></a></p>