Below figure shows the plot of which arrow head is very small...
I tried below code, but it didnot work... it said " raise AttributeError('Unknown property %s' % k) AttributeError: Unknown property headwidth"...
xyfrom=[10,620]
xyto=[130,620]
ax.annotate("",xyfrom,xyto,arrowprops=dict(arrowstyle='<->',linewidth = 2, headwidth=10,color = 'k'
))
ax.text((xyto[0]+xyfrom[0])/2-15,(xyto[1]+xyfrom[1])/2+10,"headwidth is too small",fontsize=24)
I believe it's because you need to give your arrowstyle arguments inside a string. Try this:
arrowprops=dict(arrowstyle='<->, head_width=10', facecolor='k')
, notice how this is a full string:
'<->, head_width=10'
It's a really strange choice in matplotlib, one I really don't understand why should it be this way. In any case see if solves your problem.
... since none of the above answers worked for me... here's my solution:
Use the "mutation_scale" argument! (see doc of FancyArrowPatch )
import matplotlib.pyplot as plt
f, ax = plt.subplots()
ax.scatter([1,2,3,4,5],[1,2,3,4,5])
ann = ax.annotate(rf'small head annotation',
xy=(2,2), xycoords='data',
xytext=(.28, .5), textcoords='figure fraction',
size=10, va="center", ha="center",
bbox=dict(boxstyle="round4", fc="w"),
arrowprops=dict(arrowstyle="-|>",mutation_scale=25,
connectionstyle="arc3,rad=-0.2", fc="w"))
ann2 = ax.annotate(rf'BIG head annotation',
xy=(2,2), xycoords='data',
xytext=(.75, .15), textcoords='figure fraction',
size=10, va="center", ha="center",
bbox=dict(boxstyle="round4", fc="w"),
arrowprops=dict(arrowstyle="-|>",mutation_scale=50,
connectionstyle="arc3,rad=-0.2", fc="w"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With