2015-07-03 81 views
9

這是我從功能我會在底部提供得到的錯誤:Matplotlib錯誤:乳膠無法處理以下字符串:「LP」

'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: 

這是我的功能「M使用創建上述錯誤:

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}$")。我從first graph上Matplotlib的網站採取了這種(和我試着運行該程序,以及他們提供的),我似乎無法得到它的工作。我幾乎肯定這是一個簡單的修復(就像我可能缺少一個LaTeX模塊或其他東西?)。

整個目標是能夠使用命令\displaystyle在標題和情節的標籤,讓分數變大。

我道歉,如果這是一個重複的(雖然我無法找到一個類似的問題),我只需要一個指針,讓我朝着正確的方向發展。

謝謝您的時間,

布蘭登

+1

有沒有經過「這裏是乳膠生成完整的報告:」什麼?你也可以看到,如果這是有幫助的:http://stackoverflow.com/questions/11354149/python-unable-to-render-tex-in-matplotlib –

+0

@AmyTeegarden不幸的是,不,「後下面是生成的完整報告乳膠:'它是空白的。感謝您的鏈接!我會看看type1cm。 – bjd2385

+0

你能直接處理在LaTeX的那條線,通過matplotlib沒有運行?如果它不調用'\ displaystyle',你能處理它嗎?你可以運行使用LaTeX的Matplotlib圖庫示例代碼嗎? – cphlewis

回答

0

,如果你已經安裝了乳膠您應該測試。爲此,打開一個終端輸入

which latex 

輸出應該是你的乳膠二進制文件的路徑。如果找不到,請嘗試安裝乳膠分佈。這個過程取決於你的操作系統,例如Ubuntu有幾個包。