Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib simple and two head arrows

Tags:

I would like to make a simple arrow and a two head arrow. I used the following to make a simple arrow, but I doubt this is the easiest method :

import matplotlib.pyplot as plt arr_width = .009   #  I don't know what unit it is here. fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(range(10)) ax1.arrow(1, 1, 0, .5, width = arr_width, head_width = 3 * arr_width,            head_length = 9 * arr_width) plt.show() 

I can't find how to make two head arrows with this method.

like image 607
user1850133 Avatar asked Sep 10 '14 09:09

user1850133


People also ask

Is PLT show () necessary?

draw() . Using plt. show() in Matplotlib mode is not required.

What does PLT axis () do?

The plt. axis() method allows you to set the x and y limits with a single call, by passing a list which specifies [xmin, xmax, ymin, ymax] : In [11]: plt.


1 Answers

You can create a double-headed arrow using the annotate method with blank text annotation and setting the arrowprops dict to include arrowstyle='<->' as shown below:

import matplotlib.pyplot as plt  plt.annotate(s='', xy=(1,1), xytext=(0,0), arrowprops=dict(arrowstyle='<->'))  plt.show() 

Example plot

like image 185
Ffisegydd Avatar answered Mar 22 '23 02:03

Ffisegydd