Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make arrow thinner matplotlib

I plot an arrow as below, whilst I think it's a little bit big. How can I make it thinner and smaller? Thank you

for i in range(len(x)):
    plt.annotate(df.index[i],xy=(x[i],y[i]),xytext=(x[i]+1.31,y[i]-0.55),arrowprops=dict(facecolor='blue', shrink=0.1))
like image 488
wuwucat Avatar asked Mar 22 '13 18:03

wuwucat


People also ask

How do you increase the size of an arrow in Python?

Hence, to increase the arrow's head size, you must use the mutation_scale key. import matplotlib. pyplot as plt fig, ax = plt. subplots(figsize = (5, 5)) plt.

What is quiver in Python?

Quiver plot is basically a type of 2D plot which shows vector lines as arrows. This type of plots are useful in Electrical engineers to visualize electrical potential and show stress gradients in Mechanical engineering.


1 Answers

You should try adjusting the width parameter (from the docs)

plt.annotate(df.index[i], 
    xy=(x[i],y[i]), xytext=(x[i]+1.31,y[i]-0.55),
    arrowprops=dict(facecolor='blue', shrink=0.1, width=2)
)

I've adjusted your snippet to make the parameter more obvious. Note also that width is in points, so you may need to try a few different values out. Other values worth looking at are frac. headwidth and shrink (also in the docs), especially if you want to make the head smaller too!

like image 87
danodonovan Avatar answered Oct 25 '22 00:10

danodonovan