ich eine Funktion schrieb dies automatisch zu tun, wo das Etikett eingeführt wird als Legende:
import numpy
import matplotlib.pyplot as plt
def setlabel(ax, label, loc=2, borderpad=0.6, **kwargs):
legend = ax.get_legend()
if legend:
ax.add_artist(legend)
line, = ax.plot(numpy.NaN,numpy.NaN,color='none',label=label)
label_legend = ax.legend(handles=[line],loc=loc,handlelength=0,handleheight=0,handletextpad=0,borderaxespad=0,borderpad=borderpad,frameon=False,**kwargs)
label_legend.remove()
ax.add_artist(label_legend)
line.remove()
fig,ax = plt.subplots()
ax.plot([1,2],[1,2])
setlabel(ax, '(a)')
plt.show()
Die Position des Etiketts kann contro sein Mit loc
Argument, der Abstand zur Achse kann mit borderpad
Argument gesteuert werden (negativer Wert schiebt das Label außerhalb der Abbildung), und andere Optionen legend
kann auch verwendet werden, wie fontsize
. Das obige Skript gibt eine solche Figur:
Als eine Randnotiz hat eigentlich jede Achse drei Titel (links, rechts, Mitte), aber ich erinnere mich nicht, wenn das in 1.3 oder noch nur auf Master war. – tacaswell