Ich kratze mich am ganzen Kopf für ein scheinbar einfaches Problem. Ich versuche gerade die Kopfbreite eines Pfeils in Matplotlib einzustellen.Matplotlib Unbekannte Eigenschaft "headwidth" und "head_width"
Hier ist ein Arbeitscode:
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0,2*np.pi,500)
y = np.sin(t)
fig = plt.figure(figsize=(10,5))
ax = fig.add_subplot(111)
ax.plot(t,y)
ax.annotate('', xy=(1, -1), xytext=(2, 0),
arrowprops=dict(arrowstyle='<->', facecolor='black'))
Und es zeichnet einen gut aussehenden Doppelpfeil, wie dargestellt. Nun, wenn ich die headwidth, indem Sie ändern wollen:
ax.annotate('', xy=(1, -1), xytext=(2, 0),
arrowprops=dict(arrowstyle='<->', facecolor='black',headwidth=10))
oder
ax.annotate('', xy=(1, -1), xytext=(2, 0),
arrowprops=dict(arrowstyle='<->', facecolor='black',head_width=10))
Der Fehler zurückgegeben:
AttributeError: Unknown property headwidth
oder
AttributeError: Unknown property head_width
Es ist wie ich scheint kann über Google keine Ressourcen finden, welche Addr Es besteht dieses einfache Problem. Gibt es einen Ausweg?
Vielen Dank für Ihre Zeit und Aufmerksamkeit!
Was ist Axt? Sie vermissen eine Definition von ax im Code. –
Vielen Dank für den Kopf! Ich habe es einfach hinzugefügt. Entschuldigung an alle für das fehlende Stück! –
arrowprops = dict (arrowstyle = '<->', facecolor = 'schwarz', head_width = 10) ist nur eine normale Wörterbuchinitialisierung. Es sollte keinen Fehler geben. Ich brauche Ihren vollständigen Code, um das Problem erneut zu lösen. –