LaTex in Python
Verfasst: Montag 10. Dezember 2007, 11:47
Es geht um folgendes, kleines Programm:
from Numeric import *
import numpy
from pylab import *
rc('text', usetex = True)
x=array([0.3,0.8,1.1,1.6,2.3,2.4,3.0,3.2,3.5,3.6,4.0,5.0])
y=array([0.3,0.2,1.5,2.0,1.5,1.2,2.6,3.0,2.5,3.9,2.9,4.1])
t=arange(0.0,5.0,0.05)
m,b=numpy.polyfit(x,y,1)
lin=m*t+b
plot(x,y,'bo',t,lin,'r-',linewidth=2)
setp(xlim(0.0,5.0))
setp(ylim(0.0,5.0))
xlabel('x-Werte',{'fontsize':20})
ylabel('y-Werte',{'fontsize':20})
xticks(size=18)
yticks(size=18)
title('Messdaten und lineare Regression',{'fontsize':24})
text(0.2,3.8,r'm = $\frac{ \huge \sum x_{i} \sum y_(i) - n \cdot \sum x_{i} y_{i}}{( \
\sum x_{i} )^2-n \cdot \sum x^2_{i}}$',
{'color':'r','fontsize':20})
text(0.2,3.5,r'b = $\bar{y} - a \cdot \bar{x} $',{'color':'g','fontsize':20})
show()
Sobald ich die rc und text Zeilen rausnehme gibt es kein Problem, sind sie aber drinne bekomme ich folgende, lange Fehlermeldung:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 151, in resize
self.show()
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 154, in draw
FigureCanvasAgg.draw(self)
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_agg.py", line 392, in draw
self.figure.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\figure.py", line 544, in draw
for a in self.axes: a.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 1063, in draw
a.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\axis.py", line 561, in draw
tick.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\axis.py", line 161, in draw
if self.label1On: self.label1.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 838, in draw
Text.draw(self, renderer)
File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 340, in draw
bbox, info = self._get_layout(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 187, in _get_layout
w,h = renderer.get_text_width_height(
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_agg.py", line 239, in get_text_width_height
texmanager = self.get_texmanager()
File "C:\Python24\Lib\site-packages\matplotlib\backend_bases.py", line 413, in get_texmanager
from matplotlib.texmanager import TexManager
File "C:\Python24\Lib\site-packages\matplotlib\texmanager.py", line 61, in ?
class TexManager:
File "C:\Python24\Lib\site-packages\matplotlib\texmanager.py", line 83, in TexManager
dvipngVersion = get_dvipng_version()
File "C:\Python24\Lib\site-packages\matplotlib\texmanager.py", line 58, in get_dvipng_version
raise RuntimeError('Could not obtain dvipng version')
RuntimeError: Could not obtain dvipng version
Das soll eingeltich nen Beispielprogramm sein, was ist falsch ? Oder habe ich mal wieder irgenwas vergessen ?
JJ
from Numeric import *
import numpy
from pylab import *
rc('text', usetex = True)
x=array([0.3,0.8,1.1,1.6,2.3,2.4,3.0,3.2,3.5,3.6,4.0,5.0])
y=array([0.3,0.2,1.5,2.0,1.5,1.2,2.6,3.0,2.5,3.9,2.9,4.1])
t=arange(0.0,5.0,0.05)
m,b=numpy.polyfit(x,y,1)
lin=m*t+b
plot(x,y,'bo',t,lin,'r-',linewidth=2)
setp(xlim(0.0,5.0))
setp(ylim(0.0,5.0))
xlabel('x-Werte',{'fontsize':20})
ylabel('y-Werte',{'fontsize':20})
xticks(size=18)
yticks(size=18)
title('Messdaten und lineare Regression',{'fontsize':24})
text(0.2,3.8,r'm = $\frac{ \huge \sum x_{i} \sum y_(i) - n \cdot \sum x_{i} y_{i}}{( \
\sum x_{i} )^2-n \cdot \sum x^2_{i}}$',
{'color':'r','fontsize':20})
text(0.2,3.5,r'b = $\bar{y} - a \cdot \bar{x} $',{'color':'g','fontsize':20})
show()
Sobald ich die rc und text Zeilen rausnehme gibt es kein Problem, sind sie aber drinne bekomme ich folgende, lange Fehlermeldung:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python24\lib\lib-tk\Tkinter.py", line 1345, in __call__
return self.func(*args)
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 151, in resize
self.show()
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 154, in draw
FigureCanvasAgg.draw(self)
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_agg.py", line 392, in draw
self.figure.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\figure.py", line 544, in draw
for a in self.axes: a.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\axes.py", line 1063, in draw
a.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\axis.py", line 561, in draw
tick.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\axis.py", line 161, in draw
if self.label1On: self.label1.draw(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 838, in draw
Text.draw(self, renderer)
File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 340, in draw
bbox, info = self._get_layout(renderer)
File "C:\Python24\Lib\site-packages\matplotlib\text.py", line 187, in _get_layout
w,h = renderer.get_text_width_height(
File "C:\Python24\Lib\site-packages\matplotlib\backends\backend_agg.py", line 239, in get_text_width_height
texmanager = self.get_texmanager()
File "C:\Python24\Lib\site-packages\matplotlib\backend_bases.py", line 413, in get_texmanager
from matplotlib.texmanager import TexManager
File "C:\Python24\Lib\site-packages\matplotlib\texmanager.py", line 61, in ?
class TexManager:
File "C:\Python24\Lib\site-packages\matplotlib\texmanager.py", line 83, in TexManager
dvipngVersion = get_dvipng_version()
File "C:\Python24\Lib\site-packages\matplotlib\texmanager.py", line 58, in get_dvipng_version
raise RuntimeError('Could not obtain dvipng version')
RuntimeError: Could not obtain dvipng version
Das soll eingeltich nen Beispielprogramm sein, was ist falsch ? Oder habe ich mal wieder irgenwas vergessen ?
JJ