Matplotlib - Figures anzeigen

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
Killver
User
Beiträge: 32
Registriert: Montag 12. Juli 2010, 17:03

Hey!

Ich spiele mich gerade etwas mit der matplotlib herum, weil ich sie dringend benötige. Jetzt stellt sich mir aber eine absolute noob Frage: Wie kann ich die plots auch sehen?

z.B.:

Code: Alles auswählen

figure()
h1,b1 = hist(a,bins=30)[:2]
xlabel('alpha')
bx1 = (b1[1:]+b1[:-1])/2.0
oder ein ganz simpler aufruf:

Code: Alles auswählen

pylab.loglog(...)
Ich verwende derzeit Eclipse zum debuggen.

mfg
Killver
Benutzeravatar
DaMutz
User
Beiträge: 202
Registriert: Freitag 31. Oktober 2008, 17:25

mit

Code: Alles auswählen

pylab.show()
hier noch ein bisschen ein längeres Beispiel:

Code: Alles auswählen

P.clf()
P.subplot(211)
P.plot(timescale[:endpoint], Sig[:endpoint], timescale[:endpoint], Messung[:endpoint])
P.ylabel('Amplitude [a.u.]')
P.xlabel('Zeit [s]')
P.legend(['echtes Signal', 'Messsignal'])

P.subplot(212)
P.plot(timescale[:endpoint], Smooth[:endpoint])
P.ylabel('Amplitude [a.u.]')
P.xlabel('Zeit [s]')
P.legend(['gefiltertes Signal'])

P.subplots_adjust(hspace=0.5)
P.show()
Killver
User
Beiträge: 32
Registriert: Montag 12. Juli 2010, 17:03

Sehr cool danke.

Bei folgendem Beispiel funktionierts aber iwie nicht:

Code: Alles auswählen

pylab.loglog(x,xcdf,marker='+',color='k',**kwargs)
 pylab.show();
x und xcdf sind arrays mit values, sobald ich das show dazu mach, jammert er folgendermaßen:
Traceback (most recent call last):
File "C:\python26\lib\site-packages\matplotlib\backends\backend_qt4.py", line 168, in resizeEvent
self.draw()
File "C:\python26\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 130, in draw
FigureCanvasAgg.draw(self)
File "C:\python26\lib\site-packages\matplotlib\backends\backend_agg.py", line 314, in draw
self.figure.draw(self.renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\figure.py", line 773, in draw
for a in self.axes: a.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\axes.py", line 1735, in draw
a.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\axis.py", line 742, in draw
tick.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\axis.py", line 196, in draw
self.label1.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\text.py", line 515, in draw
bbox, info = self._get_layout(renderer)
File "C:\python26\lib\site-packages\matplotlib\text.py", line 279, in _get_layout
clean_line, self._fontproperties, ismath=ismath)
File "C:\python26\lib\site-packages\matplotlib\backends\backend_agg.py", line 156, in get_text_width_height_descent
self.mathtext_parser.parse(s, self.dpi, prop)
File "C:\python26\lib\site-packages\matplotlib\mathtext.py", line 2797, in parse
font_output = fontset_class(prop, backend)
File "C:\python26\lib\site-packages\matplotlib\mathtext.py", line 658, in __init__
self._stix_fallback = StixFonts(*args, **kwargs)
File "C:\python26\lib\site-packages\matplotlib\mathtext.py", line 900, in __init__
fullpath = findfont(name)
File "C:\python26\lib\site-packages\matplotlib\font_manager.py", line 1306, in findfont
if not os.path.exists(font):
File "C:\python26\lib\genericpath.py", line 18, in exists
st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, dict found
Traceback (most recent call last):
File "C:\Program Files (x86)\pythonxy\eclipse\plugins\org.python.pydev.debug_1.5.6.2010033101\pysrc\coverage.py", line 1029, in <module>
the_coverage.command_line(sys.argv[1:])
File "C:\Program Files (x86)\pythonxy\eclipse\plugins\org.python.pydev.debug_1.5.6.2010033101\pysrc\coverage.py", line 405, in command_line
execfile(sys.argv[0], __main__.__dict__)
File "C:\Users\Killver\Desktop\MasterProjekt\code\plfit\speedcompare_plfit.py", line 19, in <module>
t1=time.time(); p1=plfit.plfit(X); print time.time()-t1
File "C:\Users\Killver\Desktop\MasterProjekt\code\plfit\plfit.py", line 50, in __init__
self.plfit(**kwargs)
File "C:\Users\Killver\Desktop\MasterProjekt\code\plfit\plfit.py", line 161, in plfit
plfit.plotcdf(self, x, xmin, alpha)
File "C:\Users\Killver\Desktop\MasterProjekt\code\plfit\plfit.py", line 209, in plotcdf
pylab.show();
File "C:\python26\lib\site-packages\matplotlib\backends\backend_qt4.py", line 69, in show
figManager.canvas.draw()
File "C:\python26\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 130, in draw
FigureCanvasAgg.draw(self)
File "C:\python26\lib\site-packages\matplotlib\backends\backend_agg.py", line 314, in draw
self.figure.draw(self.renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\figure.py", line 773, in draw
for a in self.axes: a.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\axes.py", line 1735, in draw
a.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\axis.py", line 742, in draw
tick.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
draw(artist, renderer, *kl)
File "C:\python26\lib\site-packages\matplotlib\axis.py", line 196, in draw
self.label1.draw(renderer)
File "C:\python26\lib\site-packages\matplotlib\text.py", line 515, in draw
bbox, info = self._get_layout(renderer)
File "C:\python26\lib\site-packages\matplotlib\text.py", line 279, in _get_layout
clean_line, self._fontproperties, ismath=ismath)
File "C:\python26\lib\site-packages\matplotlib\backends\backend_agg.py", line 156, in get_text_width_height_descent
self.mathtext_parser.parse(s, self.dpi, prop)
File "C:\python26\lib\site-packages\matplotlib\mathtext.py", line 2797, in parse
font_output = fontset_class(prop, backend)
File "C:\python26\lib\site-packages\matplotlib\mathtext.py", line 658, in __init__
self._stix_fallback = StixFonts(*args, **kwargs)
File "C:\python26\lib\site-packages\matplotlib\mathtext.py", line 900, in __init__
fullpath = findfont(name)
File "C:\python26\lib\site-packages\matplotlib\font_manager.py", line 1306, in findfont
if not os.path.exists(font):
File "C:\python26\lib\genericpath.py", line 18, in exists
st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, dict found
Danke und lg
philipp
Benutzeravatar
gkuhl
User
Beiträge: 600
Registriert: Dienstag 25. November 2008, 18:03
Wohnort: Hong Kong

Morgen,

wie sieht denn kwargs aus? Bekommst du den Fehler auch ohne Eclipse und wie sieht er aus?

Grüße
Gerrit


PS: Viele Matplotlib-Beispiele gibts hier: http://matplotlib.sourceforge.net/gallery.html
Zuletzt geändert von gkuhl am Mittwoch 14. Juli 2010, 10:44, insgesamt 1-mal geändert.
Killver
User
Beiträge: 32
Registriert: Montag 12. Juli 2010, 17:03

Hey!

Ja ich bekomme den Fehler auch außerhalb von eclipse.

Ich habe auch schon rein das loglog beispiel von der seite probiert. Auch da bekomm ich den Fehler nach einem Show. Auch wenn ich ein savefigure oder so probiere gehts nicht.

Verstehs echt nicht!

lg
Killver
User
Beiträge: 32
Registriert: Montag 12. Juli 2010, 17:03

Hab das Problem gefunden. Python(x,y) hat anscheinend meine matplotlib überspielt und da hat dann irgendwas nicht gepasst.
Antworten