<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Saving matplotlib polar plots on Windows 7 and Windows 10, with MiKTex 2.9.7.000, fails for some formats (e.g., pdf, svg) and works for others (e.g., png, jpg)</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['text.usetex'] = True

plt.figure()
ax = plt.subplot(111, polar=True)


plt.savefig('foo.png')  # Works
plt.savefig('foo.jpg')  # Works
plt.savefig('foo.tif')  # Works
# plt.savefig('foo.pdf')  # Fails
# plt.savefig('foo.svg')  # Fails
plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">as</span> <span class="pl-s1">mpl</span>
<span class="pl-s1">mpl</span>.<span class="pl-s1">rcParams</span>[<span class="pl-s">'text.usetex'</span>] <span class="pl-c1">=</span> <span class="pl-c1">True</span>

<span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplot</span>(<span class="pl-c1">111</span>, <span class="pl-s1">polar</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)


<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'foo.png'</span>)  <span class="pl-c"># Works</span>
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'foo.jpg'</span>)  <span class="pl-c"># Works</span>
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'foo.tif'</span>)  <span class="pl-c"># Works</span>
<span class="pl-c"># plt.savefig('foo.pdf')  # Fails</span>
<span class="pl-c"># plt.savefig('foo.svg')  # Fails</span>
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto">"Error saving .... " window pops up with error code b'tcss1000' for pdf, and b'tcss3583' for svg.  (The numbers change)</p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system:  Windows 7 &amp; 10</li>
<li>Matplotlib version: 2.2.2  or 3.0.3</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): Qt5Agg</li>
<li>Python version: 3.6</li>
<li>Jupyter version (if applicable): N/A</li>
<li>Other libraries:  N/A</li>
</ul>
<p dir="auto">Installed via Anaconda3</p>
<p dir="auto">Saving vector graphic figures with certain characters in LaTeX will fail. Here I tried to use the <code class="notranslate">\textmu</code> character. Could it be related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="207066352" data-permission-text="Title is private" data-url="https://github.com/matplotlib/matplotlib/issues/8068" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/8068/hovercard" href="https://github.com/matplotlib/matplotlib/issues/8068">#8068</a>?</p>
<p dir="auto"><strong>Code for reproduction</strong></p>

<p dir="auto">Here I'm saving to PostScript. It gives an error that I think is the most informative and points to some problems with ghostscript. Outputs for SVG and PDF below.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import matplotlib
matplotlib.rcParams['text.usetex'] = True
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_ylabel(r'\textmu')
plt.savefig('fig.ps')"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>
<span class="pl-s1">matplotlib</span>.<span class="pl-s1">rcParams</span>[<span class="pl-s">'text.usetex'</span>] <span class="pl-c1">=</span> <span class="pl-c1">True</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>

<span class="pl-s1">fig</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-c1">111</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_ylabel</span>(<span class="pl-s">r'\textmu'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'fig.ps'</span>)</pre></div>
<p dir="auto"><strong>Output - PS</strong></p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py&quot;, line 1520, in gs_distill
    report = subprocess.check_output(command, stderr=subprocess.STDOUT)
  File &quot;/usr/lib/python3.6/subprocess.py&quot;, line 336, in check_output
    **kwargs).stdout
  File &quot;/usr/lib/python3.6/subprocess.py&quot;, line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['gs', '-dBATCH', '-dNOPAUSE', '-r6000', '-sDEVICE=ps2write', '-sPAPERSIZE=letter', '-sOutputFile=/tmp/tmpt8w23igm.ps', '/tmp/tmpt8w23igm']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File &quot;Untitled.py&quot;, line 8, in &lt;module&gt;
    plt.savefig('fig.ps')
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/pyplot.py&quot;, line 701, in savefig
    res = fig.savefig(*args, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py&quot;, line 1834, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py&quot;, line 2267, in print_figure
    **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py&quot;, line 910, in print_ps
    return self._print_ps(outfile, 'ps', *args, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py&quot;, line 937, in _print_ps
    **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py&quot;, line 1359, in _print_figure_tex
    rotated=psfrag_rotated)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py&quot;, line 1525, in gs_distill
    '\n\n' % exc.output.decode(&quot;utf-8&quot;)))
RuntimeError: ghostscript was not able to process your image.
Here is the full report generated by ghostscript:
GPL Ghostscript 9.22 (2017-10-04)
Copyright (C) 2017 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in --get--
Operand stack:
   --nostringval--   --dict:9/18(ro)(L)--   112   --dict:13/13(L)--   --dict:13/13(L)--   base
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2015   1   3   %oparray_pop   2014   1   3   %oparray_pop   1998   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   %finish_stringwidth   --nostringval--   --nostringval--   14   8   0   --nostringval--   (pdf_text_enum_t)   %op_show_continue   --nostringval--
Dictionary stack:
   --dict:986/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:5/6(ro)(L)--   --dict:180/300(L)--   --dict:44/200(L)--   --dict:8/17(L)--   --dict:51/90(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 58919
GPL Ghostscript 9.22: Unrecoverable error, exit code 1"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py", line 1520, in gs_distill
    report = subprocess.check_output(command, stderr=subprocess.STDOUT)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['gs', '-dBATCH', '-dNOPAUSE', '-r6000', '-sDEVICE=ps2write', '-sPAPERSIZE=letter', '-sOutputFile=/tmp/tmpt8w23igm.ps', '/tmp/tmpt8w23igm']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "Untitled.py", line 8, in &lt;module&gt;
    plt.savefig('fig.ps')
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 701, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py", line 1834, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2267, in print_figure
    **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py", line 910, in print_ps
    return self._print_ps(outfile, 'ps', *args, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py", line 937, in _print_ps
    **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py", line 1359, in _print_figure_tex
    rotated=psfrag_rotated)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py", line 1525, in gs_distill
    '\n\n' % exc.output.decode("utf-8")))
RuntimeError: ghostscript was not able to process your image.
Here is the full report generated by ghostscript:
GPL Ghostscript 9.22 (2017-10-04)
Copyright (C) 2017 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in --get--
Operand stack:
   --nostringval--   --dict:9/18(ro)(L)--   112   --dict:13/13(L)--   --dict:13/13(L)--   base
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   2015   1   3   %oparray_pop   2014   1   3   %oparray_pop   1998   1   3   %oparray_pop   1884   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   %finish_stringwidth   --nostringval--   --nostringval--   14   8   0   --nostringval--   (pdf_text_enum_t)   %op_show_continue   --nostringval--
Dictionary stack:
   --dict:986/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:5/6(ro)(L)--   --dict:180/300(L)--   --dict:44/200(L)--   --dict:8/17(L)--   --dict:51/90(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 58919
GPL Ghostscript 9.22: Unrecoverable error, exit code 1
</code></pre></div>
<p dir="auto"><strong>Output - SVG, PDF</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;Untitled.py&quot;, line 8, in &lt;module&gt;
    plt.savefig('fig.svg')
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/pyplot.py&quot;, line 701, in savefig
    res = fig.savefig(*args, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py&quot;, line 1834, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py&quot;, line 2267, in print_figure
    **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py&quot;, line 1193, in print_svg
    return self._print_svg(filename, svgwriter, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py&quot;, line 1248, in _print_svg
    self.figure.draw(renderer)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py&quot;, line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py&quot;, line 1299, in draw
    renderer, self, artists, self.suppressComposite)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/image.py&quot;, line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py&quot;, line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py&quot;, line 2437, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/image.py&quot;, line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py&quot;, line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/axis.py&quot;, line 1147, in draw
    self.label.draw(renderer)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py&quot;, line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/text.py&quot;, line 762, in draw
    mtext=mtext)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py&quot;, line 1150, in draw_tex
    self._draw_text_as_path(gc, x, y, s, prop, angle, ismath=&quot;TeX&quot;)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py&quot;, line 950, in _draw_text_as_path
    return_new_glyphs_only=True)
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/textpath.py&quot;, line 335, in get_glyphs_tex
    font_bunch = self.tex_font_map[dvifont.texname]
  File &quot;/home/mirek/.local/lib/python3.6/site-packages/matplotlib/dviread.py&quot;, line 850, in __getitem__
    result = self._font[texname]
KeyError: b'tcss3583'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "Untitled.py", line 8, in &lt;module&gt;
    plt.savefig('fig.svg')
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 701, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py", line 1834, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2267, in print_figure
    **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 1193, in print_svg
    return self._print_svg(filename, svgwriter, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 1248, in _print_svg
    self.figure.draw(renderer)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py", line 1299, in draw
    renderer, self, artists, self.suppressComposite)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2437, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/axis.py", line 1147, in draw
    self.label.draw(renderer)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/text.py", line 762, in draw
    mtext=mtext)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 1150, in draw_tex
    self._draw_text_as_path(gc, x, y, s, prop, angle, ismath="TeX")
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py", line 950, in _draw_text_as_path
    return_new_glyphs_only=True)
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/textpath.py", line 335, in get_glyphs_tex
    font_bunch = self.tex_font_map[dvifont.texname]
  File "/home/mirek/.local/lib/python3.6/site-packages/matplotlib/dviread.py", line 850, in __getitem__
    result = self._font[texname]
KeyError: b'tcss3583'
</code></pre></div>
<p dir="auto">For PDF it's nearly identical; the last line reads:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="KeyError: b'tcss1000'"><pre class="notranslate"><code class="notranslate">KeyError: b'tcss1000'
</code></pre></div>
<p dir="auto">In case of PS and SVG, no file is produced. In case of PDF, a corrupted file results. Saving to raster formats and inline previews in jupyter notebook work fine.</p>
<p dir="auto"><strong>Matplotlib version</strong></p>

<ul dir="auto">
<li>Operating system: Debian 10</li>
<li>Matplotlib version: 2.1.1</li>
<li>Python version: 3.6.4</li>
</ul>
<p dir="auto">Matplotlib from pip. Both Matplotlib and LaTeX are installed in userspace</p>