Title: [Bug]: text.usetex Vs. DateFormatter · Issue #22350 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: text.usetex Vs. DateFormatter · Issue #22350 · matplotlib/matplotlib
X Title: [Bug]: text.usetex Vs. DateFormatter · Issue #22350 · matplotlib/matplotlib
Description: Bug summary When I set rcParams['text.usetex'] = True, I can't skip line in date format. For example, I can't use DateFormatter('%d/%m\n%Y'). Removing the skip line \n it works: '%d/%m\n%Y' --> '%d/%m/%Y'. It was working before. It's sto...
Open Graph Description: Bug summary When I set rcParams['text.usetex'] = True, I can't skip line in date format. For example, I can't use DateFormatter('%d/%m\n%Y'). Removing the skip line \n it works: '%d/%m\n%Y' --> '%d...
X Description: Bug summary When I set rcParams['text.usetex'] = True, I can't skip line in date format. For example, I can't use DateFormatter('%d/%m\n%Y'). Removing the skip line \n it wo...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22350
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: text.usetex Vs. DateFormatter","articleBody":"### Bug summary\r\n\r\nWhen I set `rcParams['text.usetex'] = True`, I can't skip line in date format. \r\n\r\nFor example, I can't use `DateFormatter('%d/%m\\n%Y')`.\r\n\r\nRemoving the skip line `\\n` it works: `'%d/%m\\n%Y' --\u003e '%d/%m/%Y'`.\r\n\r\nIt was working before. It's stopped working since my last update/upgrade of Anaconda.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib as mpl\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib.dates as dates\r\n\r\nmpl.rcParams['axes.labelsize'] = 15\r\nmpl.rcParams['figure.figsize'] = [12, 3]\r\n\r\nmpl.rcParams['text.usetex'] = True\r\n# mpl.rcParams['text.usetex'] = False\r\n\r\nFMT = dates.DateFormatter('%d/%m\\n%Y')\r\n# FMT = dates.DateFormatter('%d/%m/%Y')\r\nplt.axes().xaxis.set_major_formatter( FMT )\r\n\r\nplt.show()\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\n```\r\n---------------------------------------------------------------------------\r\nCalledProcessError Traceback (most recent call last)\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(self, command, tex, cwd)\r\n 232 try:\r\n--\u003e 233 report = subprocess.check_output(\r\n 234 command, cwd=cwd if cwd is not None else self.texcache,\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/subprocess.py in check_output(timeout, *popenargs, **kwargs)\r\n 423 \r\n--\u003e 424 return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,\r\n 425 **kwargs).stdout\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)\r\n 527 if check and retcode:\r\n--\u003e 528 raise CalledProcessError(retcode, process.args,\r\n 529 output=stdout, stderr=stderr)\r\n\r\nCalledProcessError: Command '['latex', '-interaction=nonstopmode', '--halt-on-error', '../09efec18b9a3c1b4d23927d49f15f25f.tex']' returned non-zero exit status 1.\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nRuntimeError Traceback (most recent call last)\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/IPython/core/formatters.py in __call__(self, obj)\r\n 339 pass\r\n 340 else:\r\n--\u003e 341 return printer(obj)\r\n 342 # Finally look for special method names\r\n 343 method = get_real_method(obj, self.print_method)\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, base64, **kwargs)\r\n 149 FigureCanvasBase(fig)\r\n 150 \r\n--\u003e 151 fig.canvas.print_figure(bytes_io, **kw)\r\n 152 data = bytes_io.getvalue()\r\n 153 if fmt == 'svg':\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)\r\n 2288 )\r\n 2289 with getattr(renderer, \"_draw_disabled\", nullcontext)():\r\n-\u003e 2290 self.figure.draw(renderer)\r\n 2291 \r\n 2292 if bbox_inches:\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer, *args, **kwargs)\r\n 71 @wraps(draw)\r\n 72 def draw_wrapper(artist, renderer, *args, **kwargs):\r\n---\u003e 73 result = draw(artist, renderer, *args, **kwargs)\r\n 74 if renderer._rasterizing:\r\n 75 renderer.stop_rasterizing()\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)\r\n 48 renderer.start_filter()\r\n 49 \r\n---\u003e 50 return draw(artist, renderer)\r\n 51 finally:\r\n 52 if artist.get_agg_filter() is not None:\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/figure.py in draw(self, renderer)\r\n 2801 \r\n 2802 self.patch.draw(renderer)\r\n-\u003e 2803 mimage._draw_list_compositing_images(\r\n 2804 renderer, self, artists, self.suppressComposite)\r\n 2805 \r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)\r\n 130 if not_composite or not has_images:\r\n 131 for a in artists:\r\n--\u003e 132 a.draw(renderer)\r\n 133 else:\r\n 134 # Composite any adjacent images together\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)\r\n 48 renderer.start_filter()\r\n 49 \r\n---\u003e 50 return draw(artist, renderer)\r\n 51 finally:\r\n 52 if artist.get_agg_filter() is not None:\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/axes/_base.py in draw(self, renderer)\r\n 3080 renderer.stop_rasterizing()\r\n 3081 \r\n-\u003e 3082 mimage._draw_list_compositing_images(\r\n 3083 renderer, self, artists, self.figure.suppressComposite)\r\n 3084 \r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/image.py in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)\r\n 130 if not_composite or not has_images:\r\n 131 for a in artists:\r\n--\u003e 132 a.draw(renderer)\r\n 133 else:\r\n 134 # Composite any adjacent images together\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/artist.py in draw_wrapper(artist, renderer)\r\n 48 renderer.start_filter()\r\n 49 \r\n---\u003e 50 return draw(artist, renderer)\r\n 51 finally:\r\n 52 if artist.get_agg_filter() is not None:\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/axis.py in draw(self, renderer, *args, **kwargs)\r\n 1157 \r\n 1158 ticks_to_draw = self._update_ticks()\r\n-\u003e 1159 ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,\r\n 1160 renderer)\r\n 1161 \r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/axis.py in _get_tick_bboxes(self, ticks, renderer)\r\n 1083 def _get_tick_bboxes(self, ticks, renderer):\r\n 1084 \"\"\"Return lists of bboxes for ticks' label1's and label2's.\"\"\"\r\n-\u003e 1085 return ([tick.label1.get_window_extent(renderer)\r\n 1086 for tick in ticks if tick.label1.get_visible()],\r\n 1087 [tick.label2.get_window_extent(renderer)\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/axis.py in \u003clistcomp\u003e(.0)\r\n 1083 def _get_tick_bboxes(self, ticks, renderer):\r\n 1084 \"\"\"Return lists of bboxes for ticks' label1's and label2's.\"\"\"\r\n-\u003e 1085 return ([tick.label1.get_window_extent(renderer)\r\n 1086 for tick in ticks if tick.label1.get_visible()],\r\n 1087 [tick.label2.get_window_extent(renderer)\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/text.py in get_window_extent(self, renderer, dpi)\r\n 908 \r\n 909 with cbook._setattr_cm(self.figure, dpi=dpi):\r\n--\u003e 910 bbox, info, descent = self._get_layout(self._renderer)\r\n 911 x, y = self.get_unitless_position()\r\n 912 x, y = self.get_transform().transform((x, y))\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/text.py in _get_layout(self, renderer)\r\n 315 clean_line, ismath = self._preprocess_math(line)\r\n 316 if clean_line:\r\n--\u003e 317 w, h, d = renderer.get_text_width_height_descent(\r\n 318 clean_line, self._fontproperties, ismath=ismath)\r\n 319 else:\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/backends/backend_agg.py in get_text_width_height_descent(self, s, prop, ismath)\r\n 257 texmanager = self.get_texmanager()\r\n 258 fontsize = prop.get_size_in_points()\r\n--\u003e 259 w, h, d = texmanager.get_text_width_height_descent(\r\n 260 s, fontsize, renderer=self)\r\n 261 return w, h, d\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/texmanager.py in get_text_width_height_descent(self, tex, fontsize, renderer)\r\n 333 if tex.strip() == '':\r\n 334 return 0, 0, 0\r\n--\u003e 335 dvifile = self.make_dvi(tex, fontsize)\r\n 336 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1\r\n 337 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/texmanager.py in make_dvi(self, tex, fontsize)\r\n 269 # not support.)\r\n 270 with TemporaryDirectory(dir=Path(dvifile).parent) as tmpdir:\r\n--\u003e 271 self._run_checked_subprocess(\r\n 272 [\"latex\", \"-interaction=nonstopmode\", \"--halt-on-error\",\r\n 273 f\"../{texfile.name}\"], tex, cwd=tmpdir)\r\n\r\n~/BIN/ANACONDA3_2021.11/lib/python3.9/site-packages/matplotlib/texmanager.py in _run_checked_subprocess(self, command, tex, cwd)\r\n 239 'found'.format(command[0])) from exc\r\n 240 except subprocess.CalledProcessError as exc:\r\n--\u003e 241 raise RuntimeError(\r\n 242 '{prog} was not able to process the following string:\\n'\r\n 243 '{tex!r}\\n\\n'\r\n\r\nRuntimeError: latex was not able to process the following string:\r\nb'$\\\\\\\\mathdefault{01/01'\r\n\r\nHere is the full report generated by latex:\r\nThis is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/TeX Live for SUSE Linux) (preloaded format=latex)\r\n restricted \\write18 enabled.\r\nentering extended mode\r\n(../09efec18b9a3c1b4d23927d49f15f25f.tex\r\nLaTeX2e \u003c2020-10-01\u003e patch level 4\r\nL3 programming layer \u003c2021-02-18\u003e (/usr/share/texmf/tex/latex/base/article.cls\r\nDocument Class: article 2020/04/10 v1.4m Standard LaTeX document class\r\n(/usr/share/texmf/tex/latex/base/size10.clo))\r\n(/usr/share/texmf/tex/latex/type1cm/type1cm.sty)\r\n(/usr/share/texmf/tex/latex/cm-super/type1ec.sty\r\n(/usr/share/texmf/tex/latex/base/t1cmr.fd))\r\n(/usr/share/texmf/tex/latex/base/inputenc.sty)\r\n(/usr/share/texmf/tex/latex/geometry/geometry.sty\r\n(/usr/share/texmf/tex/latex/graphics/keyval.sty)\r\n(/usr/share/texmf/tex/generic/iftex/ifvtex.sty\r\n(/usr/share/texmf/tex/generic/iftex/iftex.sty)))\r\n(/usr/share/texmf/tex/latex/underscore/underscore.sty)\r\n(/usr/share/texmf/tex/latex/base/textcomp.sty)\r\n(/usr/share/texmf/tex/latex/l3backend/l3backend-dvips.def)\r\nNo file 09efec18b9a3c1b4d23927d49f15f25f.aux.\r\n*geometry* driver: auto-detecting\r\n*geometry* detected driver: dvips\r\n! Missing $ inserted.\r\n\u003cinserted text\u003e \r\n $\r\nl.19 \\end{document}\r\n \r\nNo pages of output.\r\nTranscript written on 09efec18b9a3c1b4d23927d49f15f25f.log.\r\n```\r\n\r\n### Expected outcome\r\n\r\n\r\n\r\n\r\nIf I set `rcParams['text.usetex'] = True`, I have to change the data format:\r\n\r\n\r\n\r\n### Additional information\r\n\r\n**Has this worked in earlier versions?**\r\nYes.\r\n\r\n**Do you know why this bug is happening?**\r\nI couldn't find the LOG file cited in the **Actual outcome** (pasted above, the last line). \r\n\r\nI mean, I couldn't find this file: `Transcript written on 09efec18b9a3c1b4d23927d49f15f25f.log`.\r\n\r\nHowever I managed to find a TEX file with the same name into `'/home/.cache/matplotlib/tex.cache/'`\r\n\r\nThe contents of this TEX file are (I think it may help):\r\n\r\n`\\documentclass{article}`\r\n`\\newcommand{\\mathdefault}[1]{#1}`\r\n`\\usepackage{type1cm}`\r\n`\\usepackage{type1ec}`\r\n`\\usepackage[utf8]{inputenc}`\r\n`\\DeclareUnicodeCharacter{2212}{\\ensuremath{-}}`\r\n`\\usepackage[papersize=72in, margin=1in]{geometry}`\r\n\r\n`\\makeatletter\\@ifpackageloaded{underscore}{}{\\usepackage[strings]{underscore}}\\makeatother`\r\n`\\makeatletter\\@ifpackageloaded{textcomp}{}{\\usepackage{textcomp}}\\makeatother`\r\n`\\pagestyle{empty}`\r\n`\\begin{document}`\r\n`% The empty hbox ensures that a page is printed even for empty inputs, except`\r\n`% when using psfrag which gets confused by it.`\r\n`\\fontsize{20.000000}{25.000000}%`\r\n`\\ifdefined\\psfrag\\else\\hbox{}\\fi%`\r\n`{\\sffamily $\\mathdefault{01/01}`\r\n`\\end{document}`\r\n\r\n### Operating system\r\n\r\nOpensuse Tumbleweed\r\n\r\n### Matplotlib Version\r\n\r\n3.5.0\r\n\r\n### Matplotlib Backend\r\n\r\nmodule://matplotlib_inline.backend_inline\r\n\r\n### Python version\r\n\r\nPython 3.9.7\r\n\r\n### Jupyter version\r\n\r\njupyter lab --version: 3.2.1\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/leocirto","@type":"Person","name":"leocirto"},"datePublished":"2022-01-29T07:01:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/22350/matplotlib/issues/22350"}
| 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:aa7e728c-c45c-4569-e43d-fa669c5819ca |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD64:3E375C:276FF97:371CA28:6A50CCF2 |
| html-safe-nonce | c93856a2e48c62429dd144d8ceb771f043d754ccab493bc0b1a078c6039e2cb7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDY0OjNFMzc1QzoyNzZGRjk3OjM3MUNBMjg6NkE1MENDRjIiLCJ2aXNpdG9yX2lkIjoiNjQ2MTE1MTg1MTg2NTc1NDg2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 49b5663abc450f46e48825979182c5721c146f8a7d9f50e87ace7545d5560a44 |
| hovercard-subject-tag | issue:1118082118 |
| 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/22350/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b17cd28ebe46177226fe7d591ea835d2e4e30099149fc787c779a46b3e483365/matplotlib/matplotlib/issues/22350 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b17cd28ebe46177226fe7d591ea835d2e4e30099149fc787c779a46b3e483365/matplotlib/matplotlib/issues/22350 |
| og:image:alt | Bug summary When I set rcParams['text.usetex'] = True, I can't skip line in date format. For example, I can't use DateFormatter('%d/%m\n%Y'). Removing the skip line \n it works: '%d/%m\n%Y' --> '%d... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | leocirto |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| 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 | 08e79d53fc070870d5b168356afebb1e286a2ffe |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width