I want to draw arrows in a log-log plot that have different lengths but should have a similar-looking head. The head width is indeed the same, but the length of the head seems to scale with the arrow length. How can I get the short-looking head of the right-pointing arrow to look like the other head?
from matplotlib.pyplot import gca,show
ax = gca()
ax.set_xlim(1e-4,1e4)
ax.set_xscale('log')
ax.set_ylim(1e-4,1e4)
ax.set_yscale('log')
opt = dict(color='r',width=5)
a1 = gca().annotate('',xy=(1e-1,1e-3),xycoords='data',xytext =(1e-1,1e1),textcoords = 'data',arrowprops=opt)
a2 = gca().annotate('',xy=(1e2,1e-3), xycoords='data',xytext =(1e1,1e-3),textcoords = 'data',arrowprops=opt)
show()
You can adjust the head and connection style in the arrowprops
like this (for the full set of options see the matplotlib docs :
opt = dict(color='r',
arrowstyle = 'simple,head_width=.75,head_length=.75',
connectionstyle = 'arc3,rad=0')
Then to adjust the width of your arrow use the size
paramater in annotate
:
a1 = gca().annotate('',xy=(1e-1,1e-3),xycoords='data',xytext =(1e-1,1e1),textcoords = 'data',arrowprops=opt,size=20)
a2 = gca().annotate('',xy=(1e2,1e-3), xycoords='data',xytext =(1e1,1e-3),textcoords = 'data',arrowprops=opt,size=20)
show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.