FancyArrowPatch -|> style doesn't have solid arrowhead when linestyle='dashed'

When the -|> style was added to FancyArrowPatch, the purpose was to add an arrow style with a certain style shaft, but a solid head [1]. However, since the given linestyle is used for the outline of the head, we can have arrowheads that look very odd. Here is the example input and output:

http://aleph.sagemath.org/?q=0b7e7b41-e6cc-4cfe-b176-e42ece3565c9

from matplotlib.pyplot import figure, show
from matplotlib.patches import FancyArrowPatch

fig = figure()
ax = fig.add_subplot(111,autoscale_on=False,)
p = FancyArrowPatch((0,0), (1,1), arrowstyle='-|>,head_width=8,head_length=16',lw=3,fc='k',ec='k',linestyle='dashed')
ax.add_patch(p)
show()

Is there an easy fix to make the arrowhead have a solid linestyle, even if the shaft is dashed? Is this desirable to anyone else besides me?

Thanks,

Jason

[1] http://sourceforge.net/mailarchive/message.php?msg_id=21133511

Unfortunately, this is something that I haven't considered when
implementing the FancyArrowPatch.
As you may know, FancyArrowPatch is a single patch object (at least
viewed from outside), so you cannot have multiple linestyles that can
be set by users.

So, one option is to change the implementation to use a hard-coded
line style for arrow heads, but this is not straight forward in fact.

Another option is to use custom path effects. Attached is a modified
version of your script with this approach.
Although this makes your code more complicated, this could be the most
straight forward way.

Regards,

-JJ

fancy_arrow_linestyle.py (1.85 KB)

···

On Fri, Apr 13, 2012 at 10:30 AM, Jason Grout <jason-sage@...2130...> wrote:

When the -|> style was added to FancyArrowPatch, the purpose was to add
an arrow style with a certain style shaft, but a solid head [1].
However, since the given linestyle is used for the outline of the head,
we can have arrowheads that look very odd. Here is the example input
and output:

http://aleph.sagemath.org/?q=0b7e7b41-e6cc-4cfe-b176-e42ece3565c9

from matplotlib.pyplot import figure, show
from matplotlib.patches import FancyArrowPatch

fig = figure()
ax = fig.add_subplot(111,autoscale_on=False,)
p = FancyArrowPatch((0,0), (1,1),
arrowstyle='-|>,head_width=8,head_length=16',lw=3,fc='k',ec='k',linestyle='dashed')
ax.add_patch(p)
show()

Is there an easy fix to make the arrowhead have a solid linestyle, even
if the shaft is dashed? Is this desirable to anyone else besides me?

Thanks,

Jason

[1] http://sourceforge.net/mailarchive/message.php?msg_id=21133511

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Unfortunately, this is something that I haven't considered when
implementing the FancyArrowPatch.
As you may know, FancyArrowPatch is a single patch object (at least
viewed from outside), so you cannot have multiple linestyles that can
be set by users.

So, one option is to change the implementation to use a hard-coded
line style for arrow heads, but this is not straight forward in fact.

That was my conclusion as well. Thanks for confirming.

Another option is to use custom path effects. Attached is a modified
version of your script with this approach.
Although this makes your code more complicated, this could be the most
straight forward way.

Awesome. I've submitted a patch to Sage with your example (and credited you as an author): http://trac.sagemath.org/sage_trac/ticket/12852

Thanks,

Jason

···

On 4/15/12 10:12 AM, Jae-Joon Lee wrote: