Matplotlib 3.0.3为我提供了以下最小示例的乳胶错误消息,尤其是对于第三文本(r'a' + '\n'
)。直到今天,使用原始和非原始字符串混合时出现的此类错误消息对我来说从未出现过,我不知道空字节串(b''?)在哪里。
更新:之所以没有这样做,是因为这次我忘记删除尾随的换行符,通常我在\n
之后有非空字符串。
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams.update({'text.usetex': True,
'text.latex.preamble': [r'\boldmath'],
'text.latex.unicode': True,
})
plt.text(0.3,0.3,r'a')
plt.text(0.4,0.4,'2\n3')
plt.text(0.5,0.5,r'a' + '\n')
错误消息是:
Traceback (most recent call last):
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/backends/backend_qt5.py", line 519, in _draw_idle
self.draw()
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 402, in draw
self.figure.draw(self.renderer)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/figure.py", line 1649, in draw
renderer, self, artists, self.suppressComposite)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 2628, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/image.py", line 138, in _draw_list_compositing_images
a.draw(renderer)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/artist.py", line 50, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/text.py", line 754, in draw
mtext=mtext)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/backends/backend_agg.py", line 233, in draw_tex
Z = texmanager.get_grey(s, size, self.dpi)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/texmanager.py", line 420, in get_grey
pngfile = self.make_png(tex, fontsize, dpi)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/texmanager.py", line 385, in make_png
"-T", "tight", "-o", pngfile, dvifile], tex)
File "/scratch/seismo_proxauf/.conda/envs/proxconda3/lib/python3.6/site-packages/matplotlib/texmanager.py", line 307, in _run_checked_subprocess
exc=exc.output.decode('utf-8')))
RuntimeError: dvipng was not able to process the following string:
b''
Here is the full report generated by dvipng:
/home/proxauf/.cache/matplotlib/tex.cache/42633c70deab784e69bea3162672804e.dvi: No such file or directory
This is dvipng 1.14 Copyright 2002-2010 Jan-Ake Larsson
PS:我知道text.latex.unicode rcparam
已过时,但是,现在希望这还不是问题。