10000 Setting plt.rc('text', usetex=True) after ticker.ScalarFormatter(useMathText=True) causes Error · Issue #10317 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Setting plt.rc('text', usetex=True) after ticker.ScalarFormatter(useMathText=True) causes Error #10317
Closed
@svrnwnsch

Description

@svrnwnsch

Bug report

Bug summary

If I call plt.rc('text', usetex=True) after ticker.ScalarFormatter(useMathText=True) and plot a image with a colorbar. The plot will not work and a Latex runtime error is thrown.
If you switch the commands everything works fine.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import ticker

cbformat = ticker.ScalarFormatter(useMathText=True)
plt.rc('text', usetex=True)

plt.imshow(np.random.random((5, 5)))
plt.colorbar(format=cbformat)
plt.show()

Actual outcome

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/texmanager.py", line 393, in make_dvi
    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 '['latex', '-interaction=nonstopmode', '3a8b8f2d899e29dc96ac7c7cd31a754a.tex']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/tkinter/__init__.py", line 1702, in __call__
    return self.func(*args)
  File "/usr/lib/python3.6/tkinter/__init__.py", line 748, in callit
    func(*args)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 323, in idle_draw
    self.draw()
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 304, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_agg.py", line 430, in draw
    self.figure.draw(self.renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py", line 1299, in draw
    renderer, self, artists, self.suppressComposite)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_base.py", line 2437, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axis.py", line 1135, in draw
    renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axis.py", line 1078, in _get_tick_bboxes
    extent = tick.label2.get_window_extent(renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/text.py", line 933, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/text.py", line 317, in _get_layout
    ismath=ismath)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_agg.py", line 226, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/texmanager.py", line 602, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/texmanager.py", line 400, in make_dvi
    exc.output.decode("utf-8"))))
RuntimeError: LaTeX was not able to process the following string:
b'$\\\\mathdefault{0.6}$'

Here is the full report generated by LaTeX:
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./3a8b8f2d899e29dc96ac7c7cd31a754a.tex
LaTeX2e <2017-04-15>
Babel <3.12> and hyphenation patterns for 14 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)

Package geometry Warning: Over-specification in `h'-direction.
    `width' (5058.9pt) is ignored.


Package geometry Warning: Over-specification in `v'-direction.
    `height' (5058.9pt) is ignored.

)
No file 3a8b8f2d899e29dc96ac7c7cd31a754a.aux.
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
! Undefined control sequence.
<recently read> \mathdefault 
                             
l.12 ...000000}{12.500000}{\sffamily $\mathdefault
                                                  {0.6}$}
[1] (./3a8b8f2d899e29dc96ac7c7cd31a754a.aux) )
(see the transcript file for additional information)
Output written on 3a8b8f2d899e29dc96ac7c7cd31a754a.dvi (1 page, 288 bytes).
Transcript written on 3a8b8f2d899e29dc96ac7c7cd31a754a.log.
 


Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/texmanager.py", line 393, in make_dvi
    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 '['latex', '-interaction=nonstopmode', '3763d70561037cddae6a97acb53ffec4.tex']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/tkinter/__init__.py", line 1702, in __call__
    return self.func(*args)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 233, in resize
    self.show()
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_tkagg.py", line 304, in draw
    FigureCanvasAgg.draw(self)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_agg.py", line 430, in draw
    self.figure.draw(self.renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py", line 1299, in draw
    renderer, self, artists, self.suppressComposite)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axes/_base.py", line 2437, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
    a.draw(renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/artist.py", line 55, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axis.py", line 1135, in draw
    renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/axis.py", line 1078, in _get_tick_bboxes
    extent = tick.label2.get_window_extent(renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/text.py", line 933, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/text.py", line 317, in _get_layout
    ismath=ismath)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/backend_agg.py", line 226, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/texmanager.py", line 602, in get_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/texmanager.py", line 400, in make_dvi
    exc.output.decode("utf-8"))))
RuntimeError: LaTeX was not able to process the following string:
b'$\\\\mathdefault{0.8}$'

Here is the full report generated by LaTeX:
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./3763d70561037cddae6a97acb53ffec4.tex
LaTeX2e <2017-04-15>
Babel <3.12> and hyphenation patterns for 14 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)

Package geometry Warning: Over-specification in `h'-direction.
    `width' (5058.9pt) is ignored.


Package geometry Warning: Over-specification in `v'-direction.
    `height' (5058.9pt) is ignored.

)
No file 3763d70561037cddae6a97acb53ffec4.aux.
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
! Undefined control sequence.
<recently read> \mathdefault 
                             
l.12 ...000000}{12.500000}{\sffamily $\mathdefault
                                                  {0.8}$}
[1] (./3763d70561037cddae6a97acb53ffec4.aux) )
(see the transcript file for additional information)
Output written on 3763d70561037cddae6a97acb53ffec4.dvi (1 page, 288 bytes).
Transcript written on 3763d70561037cddae6a97acb53ffec4.log.

Matplotlib version

  • Operating system: Kubuntu 17.10
  • Matplotlib version: 2.1.1
  • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
  • Python version: 3.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0