Say I haben die folgende Einstellung:Achsen Methoden in matplotlib
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(5)
y = np.exp(x)
fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
ax1.plot(x, y)
Ich mag würde ein Titel auf die Zeichnung hinzuzufügen (oder zu dem subplot).
Ich habe versucht:
> fig1.title('foo')
AttributeError: 'Figure' object has no attribute 'title'
und
> ax1.title('foo')
TypeError: 'Text' object is not callable
Wie kann ich die objektorientierte Programmierung Schnittstelle verwenden, um matplotlib diese Attribute zu setzen?
Allgemeiner, wo finde ich die Hierarchie der Klassen in Matplotlib und ihre entsprechenden Methoden?
Auf meinem System (Ubuntu 13.10, ipython 1.1.0, python 2.7.5, matplotlib 1.2.1) Ich brauche eine 'fig1.show()' nach dem 'ax1.set_title (...) c alles um sichtbare Wirkung zu erzielen. Meine Vermutung ist, dass dies Standardverhalten ist. –
@RoryYorke yep, Sie müssen standardmäßig show() aufrufen. – zhangxaochen
FWIW, 'figure' hat die' suptitle' Methode, mit der Sie einen Titel über mehrere Unterplots setzen können. – physicsmichael