Dear friends, I just start to use matplotlib, which looks
> quite promising for me. I need to draw a couple of arrows
> in my 2D plot. Is there a simple way to get it work?
> Any suggustions are welcome.
I recommend creating an arrow class, derived from matplotlib.artist.Artist, that
contains a matplotlib.lines.Line2D for the arrow stem and a
matplotlib.patches.RegularPolygon with numVertices=3 for the arrow
head. You can control the rotation of the arrowhead with the
Once you have this class so defined, you can add it instances of it to
the axes with ax.add_artist(arrow).
I'll be happy to help out with a prototype if you have trouble. Take
a look at matplotlib.table.Cell, which John Gill wrote to support
tables. You can use this as a simple model for how to write new
artists (things that draw into a figure) composed of other artists.
It would be nice to have a fancy arrow class, that supported text
labeling, at the base, along the stem and at the arrowhead. You could
also consider a more sophisticated polygon other than a triangle for
Finally, if you needed to draw *a lot of arrows*, order of a thousand
or more (eg for direction fields), a
matplotlib.collections.PolygonCollection would be the way to go for