Title: savefig to vector graphics with LaTeX fails with certain characters · Issue #10272 · matplotlib/matplotlib · GitHub
Open Graph Title: savefig to vector graphics with LaTeX fails with certain characters · Issue #10272 · matplotlib/matplotlib
X Title: savefig to vector graphics with LaTeX fails with certain characters · Issue #10272 · matplotlib/matplotlib
Description: Saving vector graphic figures with certain characters in LaTeX will fail. Here I tried to use the \textmu character. Could it be related to #8068? Code for reproduction Here I'm saving to PostScript. It gives an error that I think is the...
Open Graph Description: Saving vector graphic figures with certain characters in LaTeX will fail. Here I tried to use the \textmu character. Could it be related to #8068? Code for reproduction Here I'm saving to PostScrip...
X Description: Saving vector graphic figures with certain characters in LaTeX will fail. Here I tried to use the \textmu character. Could it be related to #8068? Code for reproduction Here I'm saving to PostS...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/10272
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"savefig to vector graphics with LaTeX fails with certain characters","articleBody":"Saving vector graphic figures with certain characters in LaTeX will fail. Here I tried to use the `\\textmu` character. Could it be related to #8068?\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug, also minimizing the number of dependencies required--\u003e\r\n\r\nHere 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.\r\n\r\n```python\r\nimport matplotlib\r\nmatplotlib.rcParams['text.usetex'] = True\r\nimport matplotlib.pyplot as plt\r\n\r\nfig = plt.figure()\r\nax = fig.add_subplot(111)\r\nax.set_ylabel(r'\\textmu')\r\nplt.savefig('fig.ps')\r\n```\r\n\r\n**Output - PS**\r\n\r\n\u003c!--The output produced by the above code, which may be a screenshot, console output, etc.--\u003e\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py\", line 1520, in gs_distill\r\n report = subprocess.check_output(command, stderr=subprocess.STDOUT)\r\n File \"/usr/lib/python3.6/subprocess.py\", line 336, in check_output\r\n **kwargs).stdout\r\n File \"/usr/lib/python3.6/subprocess.py\", line 418, in run\r\n output=stdout, stderr=stderr)\r\nsubprocess.CalledProcessError: Command '['gs', '-dBATCH', '-dNOPAUSE', '-r6000', '-sDEVICE=ps2write', '-sPAPERSIZE=letter', '-sOutputFile=/tmp/tmpt8w23igm.ps', '/tmp/tmpt8w23igm']' returned non-zero exit status 1.\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n File \"Untitled.py\", line 8, in \u003cmodule\u003e\r\n plt.savefig('fig.ps')\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/pyplot.py\", line 701, in savefig\r\n res = fig.savefig(*args, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py\", line 1834, in savefig\r\n self.canvas.print_figure(fname, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py\", line 2267, in print_figure\r\n **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py\", line 910, in print_ps\r\n return self._print_ps(outfile, 'ps', *args, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py\", line 937, in _print_ps\r\n **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py\", line 1359, in _print_figure_tex\r\n rotated=psfrag_rotated)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_ps.py\", line 1525, in gs_distill\r\n '\\n\\n' % exc.output.decode(\"utf-8\")))\r\nRuntimeError: ghostscript was not able to process your image.\r\nHere is the full report generated by ghostscript:\r\nGPL Ghostscript 9.22 (2017-10-04)\r\nCopyright (C) 2017 Artifex Software, Inc. All rights reserved.\r\nThis software comes with NO WARRANTY: see the file PUBLIC for details.\r\nError: /undefined in --get--\r\nOperand stack:\r\n --nostringval-- --dict:9/18(ro)(L)-- 112 --dict:13/13(L)-- --dict:13/13(L)-- base\r\nExecution stack:\r\n %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--\r\nDictionary stack:\r\n --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)--\r\nCurrent allocation mode is local\r\nLast OS error: No such file or directory\r\nCurrent file position is 58919\r\nGPL Ghostscript 9.22: Unrecoverable error, exit code 1\r\n```\r\n\r\n**Output - SVG, PDF**\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"Untitled.py\", line 8, in \u003cmodule\u003e\r\n plt.savefig('fig.svg')\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/pyplot.py\", line 701, in savefig\r\n res = fig.savefig(*args, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py\", line 1834, in savefig\r\n self.canvas.print_figure(fname, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py\", line 2267, in print_figure\r\n **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 1193, in print_svg\r\n return self._print_svg(filename, svgwriter, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 1248, in _print_svg\r\n self.figure.draw(renderer)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/figure.py\", line 1299, in draw\r\n renderer, self, artists, self.suppressComposite)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/image.py\", line 138, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py\", line 2437, in draw\r\n mimage._draw_list_compositing_images(renderer, self, artists)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/image.py\", line 138, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/axis.py\", line 1147, in draw\r\n self.label.draw(renderer)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/artist.py\", line 55, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/text.py\", line 762, in draw\r\n mtext=mtext)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 1150, in draw_tex\r\n self._draw_text_as_path(gc, x, y, s, prop, angle, ismath=\"TeX\")\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/backends/backend_svg.py\", line 950, in _draw_text_as_path\r\n return_new_glyphs_only=True)\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/textpath.py\", line 335, in get_glyphs_tex\r\n font_bunch = self.tex_font_map[dvifont.texname]\r\n File \"/home/mirek/.local/lib/python3.6/site-packages/matplotlib/dviread.py\", line 850, in __getitem__\r\n result = self._font[texname]\r\nKeyError: b'tcss3583'\r\n```\r\nFor PDF it's nearly identical; the last line reads: \r\n```\r\nKeyError: b'tcss1000'\r\n```\r\n\r\nIn 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.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: Debian 10\r\n * Matplotlib version: 2.1.1\r\n * Python version: 3.6.4\r\n\r\nMatplotlib from pip. Both Matplotlib and LaTeX are installed in userspace\r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/miromarszal","@type":"Person","name":"miromarszal"},"datePublished":"2018-01-20T18:20:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":16},"url":"https://github.com/10272/matplotlib/issues/10272"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:879fd268-6fc4-682f-24cf-7e30bb210690 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA8A:217E0D:61E2A7:8438F1:6A5254CF |
| html-safe-nonce | 91aee95f3ef44e5c8992fd86f73cd3fc76e19ae06d4c8130da7c54a89fdc2226 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQThBOjIxN0UwRDo2MUUyQTc6ODQzOEYxOjZBNTI1NENGIiwidmlzaXRvcl9pZCI6IjI5NjY5OTEwNDM2ODAxNjMwMjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9abe1a1d0eedbd26371675e4f2126d29f365957af4933b15689fc5b8890de6d7 |
| hovercard-subject-tag | issue:290212154 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/10272/issue_layout |
| twitter:image | https://opengraph.githubassets.com/edc428b84fc1d853a9d2aa6541dd6a922fbab4bd42e944c2da1236c15a70d198/matplotlib/matplotlib/issues/10272 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/edc428b84fc1d853a9d2aa6541dd6a922fbab4bd42e944c2da1236c15a70d198/matplotlib/matplotlib/issues/10272 |
| og:image:alt | Saving vector graphic figures with certain characters in LaTeX will fail. Here I tried to use the \textmu character. Could it be related to #8068? Code for reproduction Here I'm saving to PostScrip... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | miromarszal |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width