Wenn ich pyplot.title('some string')
aufrufen, löst es die Ausnahme 'str' object is not callable'
. Ich kopierte die folgenden von der matplotlib Online-Dokumentation:Matplotlib pyplot.title (string) gibt Fehler
mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)
# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title('Histogram of IQ')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
plt.axis([40, 160, 0, 0.03])
plt.grid(True)
plt.show()
und bekommen
TypeError Traceback (most recent call last)
<ipython-input-158-40fe7a831b06> in <module>()
8 plt.xlabel('Smarts')
9 plt.ylabel('Probability')
---> 10 plt.title('Histogram of IQ')
11 plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
12 plt.axis([40, 160, 0, 0.03])
TypeError: 'str' object is not callable
pyplot.suptitle()
OK
arbeitet Ich bin mit Python 2.7.5 und die neueste Version von matplotlib auf ein iMac mit einem I7-Prozessor OSX 10.8 und 8 Gig RAM und Ipython-Notebook.
Weiß jemand, was los ist?
Es funktioniert für mich auf OSX 10.8.5 mit Python 2.7.5 und Matplotlib 1.3.0. Wie hast du ipython und matplotlib installiert? Ist der obige Code der einzige Code, den Sie hervorrufen? Führst du 'ipython notebook --pylab' oder wie initialisierst du es? –
Ich kann das auch nicht reproduzieren. Hast du einen "plt.title = 'blah" irgendwo in deinem Code? – tacaswell
Ich neu installiert Matplotlib (Pip uninstall dann pip installieren) und alles ist in Ordnung. Zuvor sagte mir plt.title, dass plt.title eine Saite sei. Jetzt bestätigt es, dass plt.title eine Funktion ist. Ich bin mir nicht sicher, ob ich alles herausbekommen habe, aber es funktioniert. Danke Leute. – olben1