Title: UnicodeDecodeError when making a plot using the 'classic' style and text.usetex=True · Issue #8423 · matplotlib/matplotlib · GitHub
Open Graph Title: UnicodeDecodeError when making a plot using the 'classic' style and text.usetex=True · Issue #8423 · matplotlib/matplotlib
X Title: UnicodeDecodeError when making a plot using the 'classic' style and text.usetex=True · Issue #8423 · matplotlib/matplotlib
Description: Bug report When making a plot using the 'classic' style, matplotlib overrides the default value for text.latex.unicode, setting it to False. This causes a problem for any plot that has negative numbers in any label, because matplotlib no...
Open Graph Description: Bug report When making a plot using the 'classic' style, matplotlib overrides the default value for text.latex.unicode, setting it to False. This causes a problem for any plot that has negative num...
X Description: Bug report When making a plot using the 'classic' style, matplotlib overrides the default value for text.latex.unicode, setting it to False. This causes a problem for any plot that has nega...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/8423
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"UnicodeDecodeError when making a plot using the 'classic' style and text.usetex=True","articleBody":"### Bug report\r\n\r\nWhen making a plot using the 'classic' style, matplotlib overrides the default value for `text.latex.unicode`, setting it to `False`. This causes a problem for any plot that has negative numbers in any label, because matplotlib now uses a unicode symbol to represent the negative sign.\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib import rcParams\r\nrcParams['text.usetex'] = True\r\n\r\n# Example data\r\nt = np.arange(-1.0, 1.0 + 0.01, 0.01)\r\ns = np.cos(4 * np.pi * t) + 2\r\n\r\nplt.plot(t, s)\r\n\r\nwith plt.style.context('classic'):\r\n plt.savefig('tex_demo')\r\n```\r\n\r\n**Actual outcome**\r\n\r\nThe following traceback:\r\n\r\n```\r\n File \"test_mpl.py\", line 14, in \u003cmodule\u003e\r\n plt.savefig('tex_demo')\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/pyplot.py\", line 707, in savefig\r\n res = fig.savefig(*args, **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/figure.py\", line 1763, in savefig\r\n self.canvas.print_figure(*args, **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/backend_bases.py\", line 2234, in print_figure\r\n **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/backends/backend_agg.py\", line 548, in print_png\r\n FigureCanvasAgg.draw(self)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/backends/backend_agg.py\", line 467, in draw\r\n self.figure.draw(self.renderer)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/artist.py\", line 68, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/figure.py\", line 1240, in draw\r\n renderer, self, artists, self.suppressComposite)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/image.py\", line 139, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/artist.py\", line 68, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/axes/_base.py\", line 2386, in draw\r\n mimage._draw_list_compositing_images(renderer, self, artists)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/image.py\", line 139, in _draw_list_compositing_images\r\n a.draw(renderer)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/artist.py\", line 68, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/axis.py\", line 1118, in draw\r\n tick.draw(renderer)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/artist.py\", line 68, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/axis.py\", line 268, in draw\r\n self.label1.draw(renderer)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/artist.py\", line 68, in draw_wrapper\r\n return draw(artist, renderer, *args, **kwargs)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/text.py\", line 797, in draw\r\n mtext=mtext)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/backends/backend_agg.py\", line 255, in draw_tex\r\n Z = texmanager.get_grey(s, size, self.dpi)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/texmanager.py\", line 585, in get_grey\r\n pngfile = self.make_png(tex, fontsize, dpi)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/texmanager.py\", line 508, in make_png\r\n dvifile = self.make_dvi(tex, fontsize)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/texmanager.py\", line 400, in make_dvi\r\n texfile = self.make_tex(tex, fontsize)\r\n File \"/Users/goldbaum/Documents/matplotlib-git/lib/matplotlib/texmanager.py\", line 311, in make_tex\r\n if rcParams['text.latex.unicode']:\r\nUnicodeEncodeError: 'ascii' codec can't encode character '\\u2212' in position 298: ordinal not in range(128)\r\n```\r\n\r\n**Expected outcome**\r\n\r\nThe plot should be saved to disk without erroring. The script runs without error on matplotlib 1.5.3.\r\n\r\n**Matplotlib version**\r\n\r\nMatplotlib 2.0.0 on OSX, installed via pip.\r\n\r\n","author":{"url":"https://github.com/ngoldbaum","@type":"Person","name":"ngoldbaum"},"datePublished":"2017-04-03T22:45:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/8423/matplotlib/issues/8423"}
| 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:4c36cac5-e87f-30d9-28ee-db43b2df256c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C8C2:3D4E09:1224383:18B4377:6A55C7D1 |
| html-safe-nonce | 3980fcb4b45a6a915c8af2d5cb26641e04717f0936c5e16600cff22d8397179e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOEMyOjNENEUwOToxMjI0MzgzOjE4QjQzNzc6NkE1NUM3RDEiLCJ2aXNpdG9yX2lkIjoiMTEwNDUwMDgzOTY2NDY5OTM0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 40c080efeeb762ae58ad7c3a51aeb76a9163384c855ddc6452b608a9eb4dc727 |
| hovercard-subject-tag | issue:219083147 |
| 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/8423/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e16f5a2d51e8fcc556f176941c465323ec00791deac4fcc0442da1e8c6ce5421/matplotlib/matplotlib/issues/8423 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e16f5a2d51e8fcc556f176941c465323ec00791deac4fcc0442da1e8c6ce5421/matplotlib/matplotlib/issues/8423 |
| og:image:alt | Bug report When making a plot using the 'classic' style, matplotlib overrides the default value for text.latex.unicode, setting it to False. This causes a problem for any plot that has negative num... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ngoldbaum |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| 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 | 8f8e1726192df8dce16872ceb503336c12e9ae78 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width