Hello,

I want do add an arrow *tip* to a line with the same angle.

I have tried this:

from pylab import *
from matplotlib import collections, transforms

def MyArrow(ax, x, y, ang, scale=50, over=.5, color='k'):
    ar = [(0,0), (-.5,-over), (0,1), (.5,-over), (0,0)]
    col = collections.PolyCollection(
        [ar],
        offsets=(x, y),
        transOffset=ax.transData,
        color=color
    )
    col.set_transform(transforms.Affine2D().rotate(ang).scale(scale))
    ax.add_collection(col)

plot([0,1,2], '.-', lw=2)
MyArrow(gca(), .5, .5, -pi/4)
draw()

and I get an arrow tip without the same line angle :-( See the attached
image.

Can you help me to get the right transformation?

Thanks,

  Friedrich

<<attachment: arrow.png>>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to