Adding an arrowhead marker

Hi,

In my work I've come across a need to plot arrows with a position
specified in data coordinates but which appear in the rendered plot with
a constant size and shape, independent of zoom or aspect ratio (as
opposed to the patch.Arrow class which acts like a vector image of an
arrow and as such changes in rendered size on zooming or aspect ratio
change).

It appeared to me that the most obvious way to implement this was as a
new arrowhead marker style for the lines.Line2D class (with no marker
shown for the first point in the line). This should allow more general
use than just as simple arrows; for example in plotting vectors.

I've attached a patch to CVS to implement this as a marker accessed
using the symbol 'a'. The marker is a triangle pointing in the correct
direction for an an arrowhead and with its point at the end of the line
segment.

There are two main problems with the attached code. Firstly as the
arrowhead is potentially pointing in a different direction for each
point the renderer.draw_markers method can't be used and plotting will
thus be slower. Secondly, for linewidth > 1 the line appears either
side of the point of the arrowhead. I can see two potential ways
around the second problem: moving the arrowhead forwards which is
unsuitable for vectors or altering the length of lines plotted where the
marker is an arrowhead which requires lots more code than it seemed
sensible to add.

Anyway, despite the problems noted I thought this code might be
generally useful.

Nick

patch (1.41 KB)