Matplotlib 错误:LaTeX 无法处理以下字符串:'lp' [英] Matplotlib Error: LaTeX was not able to process the following string: 'lp'

查看:251
本文介绍了Matplotlib 错误:LaTeX 无法处理以下字符串:'lp'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我从底部提供的函数中得到的错误:

This is the error I'm getting from the function I'll provide at the bottom:

'latex' is not recognized as an internal or external command,
operable program or batch file.
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\python27\lib\lib-tk\Tkinter.py", line 1486, in __call__
    return self.func(*args)
  File "C:\python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", lin
e 278, in resize
    self.show()
  File "C:\python27\lib\site-packages\matplotlib\backends\backend_tkagg.py", lin
e 349, in draw
    FigureCanvasAgg.draw(self)
  File "C:\python27\lib\site-packages\matplotlib\backends\backend_agg.py", line
469, in draw
    self.figure.draw(self.renderer)
  File "C:\python27\lib\site-packages\matplotlib\artist.py", line 59, in draw_wr
apper
    draw(artist, renderer, *args, **kwargs)
  File "C:\python27\lib\site-packages\matplotlib\figure.py", line 1079, in draw
    func(*args)
  File "C:\python27\lib\site-packages\matplotlib\artist.py", line 59, in draw_wr
apper
    draw(artist, renderer, *args, **kwargs)
  File "C:\python27\lib\site-packages\matplotlib\axes\_base.py", line 2092, in d
raw
    a.draw(renderer)
  File "C:\python27\lib\site-packages\matplotlib\artist.py", line 59, in draw_wr
apper
    draw(artist, renderer, *args, **kwargs)
  File "C:\python27\lib\site-packages\matplotlib\axis.py", line 1116, in draw
    renderer)
  File "C:\python27\lib\site-packages\matplotlib\axis.py", line 1065, in _get_ti
ck_bboxes
    extent = tick.label1.get_window_extent(renderer)
  File "C:\python27\lib\site-packages\matplotlib\text.py", line 741, in get_wind
ow_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "C:\python27\lib\site-packages\matplotlib\text.py", line 311, in _get_lay
out
    ismath=False)
  File "C:\python27\lib\site-packages\matplotlib\backends\backend_agg.py", line
223, in get_text_width_height_descent
    renderer=self)
  File "C:\python27\lib\site-packages\matplotlib\texmanager.py", line 670, in ge
t_text_width_height_descent
    dvifile = self.make_dvi(tex, fontsize)
  File "C:\python27\lib\site-packages\matplotlib\texmanager.py", line 417, in ma
ke_dvi
    report))
RuntimeError: LaTeX was not able to process the following string:
'lp'
Here is the full report generated by LaTeX:

这是我正在使用的导致上述错误的函数:

This is the function I'm using that creates the above error:

def Derivative( inputArrayList,rowNumber_from_top ):
    for image in inputArrayList:
        rowValues = image[0][rowNumber_from_top]
        for i in range(len(rowValues)):         
            # Perform the difference derivative estimation
            if i == 0 or i == (len(rowValues) - 1):
                rowValues[ i ] = 0 # set edges to 0
            else:
                derivative = (rowValues[ i+1 ] - rowValues[ i-1 ])/(2.0)
                rowValues[ i ] = derivative
        plt.rc('text', usetex=True)
        plt.rc('font', family='serif')
        plt.plot(rowValues,color="k")
        plt.ylim( (0,image.max() + 10.0) )
        plt.title(r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$")
        plt.show()

请注意行 plt.title(r"$ \ displaystyle \ sum_ {n = 1} ^ \ infty \ frac {-e ^ {i \ pi}} {2 ^ n} $").我从 Matplotlib 网站上的 第一张图 中获取了这个(而且我也尝试过运行它们提供的程序),但似乎无法正常工作.我几乎可以肯定这是一个简单的修复程序(例如,也许我缺少LaTeX模块之类的东西?).

Notice the line plt.title(r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$"). I've taken this from the first graph on Matplotlib's site (and I've tried running that program as well that they provide) and I cannot seem to get it to work. I'm almost certain it's a simple fix (like maybe I'm missing a LaTeX module or something?).

整个目标是能够在图的标题和标签中使用命令 \displaystyle 来放大分数.

The whole goal was to be able to use the command \displaystyle in the title and labels of the plot to make fractions larger.

很抱歉,如果这是重复的(尽管我找不到类似的问题),我只需要一个指针就可以使我朝正确的方向前进.

I apologize if this is a duplicate (although I can't find a similar issue), I just need a pointer to get me going in the right direction.

感谢您的时间,

布兰登

推荐答案

您似乎缺少用于 dvi 渲染的包.在基于 debian 的发行版上,这应该足以获得所有需要的包:

It seems you are missing a package for the dvi rendering. On debian-based distributions, this should suffice to get all the needed packages:

sudo apt-get install texlive-latex-extra texlive-fonts-recommended dvipng cm-super

这篇关于Matplotlib 错误:LaTeX 无法处理以下字符串:'lp'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆