Closed
Description
Bug report
Bug summary
The sample script given in
https://matplotlib.org/gallery/text_labels_and_annotations/tex_demo.html?highlight=tex
does not work, producing a large number of error messages and an empty (blank) plotting window.
Code for reproduction
import numpy as np
import matplotlib
matplotlib.rcParams['text.usetex'] = True
import matplotlib.pyplot as plt
t = np.linspace(0.0, 1.0, 100)
s = np.cos(4 * np.pi * t) + 2
fig, ax = plt.subplots(figsize=(6, 4), tight_layout=True)
ax.plot(t, s)
ax.set_xlabel(r'\textbf{time (s)}')
ax.set_ylabel('\\textit{Velocity (\N{DEGREE SIGN}/sec)}', fontsize=16)
ax.set_title(r'\TeX\ is Number $\displaystyle\sum_{n=1}^\infty'
r'\frac{-e^{i\pi}}{2^n}$!', fontsize=16, color='r')
plt.show()
Actual outcome
F:\Documents\Programs\Python>python TestTeX2.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python\lib\lib-tk\Tkinter.py", line 1541, in __call__
return self.func(*args)
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\_backend_tk.py", line 227, in resize
self.draw()
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 12, in draw
super(FigureCanvasTkAgg, self).draw()
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\backend_agg.py", line 437, in draw
self.figure.draw(self.renderer)
File "C:\Program Files\Python\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:\Program Files\Python\lib\site-packages\matplotlib\figure.py", line 1484, in draw
**self._tight_parameters)
File "C:\Program Files\Python\lib\site-packages\matplotlib\figure.py", line 2307, in tight_layout
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "C:\Program Files\Python\lib\site-packages\matplotlib\tight_layout.py", line 349, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "C:\Program Files\Python\lib\site-packages\matplotlib\tight_layout.py", line 115, in auto_adjust_subplotpars
if ax.get_visible()])
File "C:\Program Files\Python\lib\site-packages\matplotlib\axes\_base.py", line 4192, in get_tightbbox
bb.append(self.title.get_window_extent(renderer))
File "C:\Program Files\Python\lib\site-packages\matplotlib\text.py", line 924, in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File "C:\Program Files\Python\lib\site-packages\matplotlib\text.py", line 309, in _get_layout
ismath=ismath)
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\backend_agg.py", line 236, in get_text_width_height_descent
s, fontsize, renderer=self)
File "C:\Program Files\Python\lib\site-packages\matplotlib\texmanager.py", line 501, in get_text_width_height_descent
dvifile = self.make_dvi(tex, fontsize)
File "C:\Program Files\Python\lib\site-packages\matplotlib\texmanager.py", line 365, in make_dvi
texfile], tex)
File "C:\Program Files\Python\lib\site-packages\matplotlib\texmanager.py", line 335, in _run_checked_subprocess
stderr=subprocess.STDOUT)
File "C:\Program Files\Python\lib\subprocess.py", line 216, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Program Files\Python\lib\subprocess.py", line 394, in __init__
errread, errwrite)
File "C:\Program Files\Python\lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python\lib\lib-tk\Tkinter.py", line 1541, in __call__
return self.func(*args)
File "C:\Program Files\Python\lib\lib-tk\Tkinter.py", line 592, in callit
func(*args)
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\_backend_tk.py", line 310, in idle_draw
self.draw()
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 12, in draw
super(FigureCanvasTkAgg, self).draw()
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\backend_agg.py", line 437, in draw
self.figure.draw(self.renderer)
File "C:\Program Files\Python\lib\site-packages\matplotlib\artist.py", line 55, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "C:\Program Files\Python\lib\site-packages\matplotlib\figure.py", line 1484, in draw
**self._tight_parameters)
File "C:\Program Files\Python\lib\site-packages\matplotlib\figure.py", line 2307, in tight_layout
pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
File "C:\Program Files\Python\lib\site-packages\matplotlib\tight_layout.py", line 349, in get_tight_layout_figure
pad=pad, h_pad=h_pad, w_pad=w_pad)
File "C:\Program Files\Python\lib\site-packages\matplotlib\tight_layout.py", line 115, in auto_adjust_subplotpars
if ax.get_visible()])
File "C:\Program Files\Python\lib\site-packages\matplotlib\axes\_base.py", line 4192, in get_tightbbox
bb.append(self.title.get_window_extent(renderer))
File "C:\Program Files\Python\lib\site-packages\matplotlib\text.py", line 924, in get_window_extent
bbox, info, descent = self._get_layout(self._renderer)
File "C:\Program Files\Python\lib\site-packages\matplotlib\text.py", line 309, in _get_layout
ismath=ismath)
File "C:\Program Files\Python\lib\site-packages\matplotlib\backends\backend_agg.py", line 236, in get_text_width_height_descent
s, fontsize, renderer=self)
File "C:\Program Files\Python\lib\site-packages\matplotlib\texmanager.py", line 501, in get_text_width_height_descent
dvifile = self.make_dvi(tex, fontsize)
File "C:\Program Files\Python\lib\site-packages\matplotlib\texmanager.py", line 365, in make_dvi
texfile], tex)
File "C:\Program Files\Python\lib\site-packages\matplotlib\texmanager.py", line 335, in _run_checked_subprocess
stderr=subprocess.STDOUT)
File "C:\Program Files\Python\lib\subprocess.py", line 216, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Program Files\Python\lib\subprocess.py", line 394, in __init__
errread, errwrite)
File "C:\Program Files\Python\lib\subprocess.py", line 644, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Matplotlib version
- Windows 10
- Matplotlib 2.2.3
- Matplotlib backend: TkAgg
- Python version: 2.7.15
- Jupyter version (if applicable): ---
- Other libraries: numpy
Matplotlib was installed through pip.