Matplotlib数据库打印文本错误消息是否为空字符串?

2024-09-24 22:20:30 发布

您现在位置:Python中文网/ 问答频道 /正文

matplotlib3.0.3为下面的最小示例提供了一个latex错误消息,特别是对于第三个文本(r'a' + '\n')。直到今天,在使用原始字符串和非原始字符串混合时,我才发现这样的错误消息,我不知道空的bytestring(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

附言:我知道text.latex.unicode rcparam已经被否决了,但我希望现在这还不是一个问题。你知道吗


Tags: inpymatplotliblibpackageslinesiteconda