How to remove the whitespace between the tip of the arrow of a FancyArrowPatch and the target points?

前端 未结 1 890
孤街浪徒
孤街浪徒 2021-01-24 22:31

When doing an image which puts lots of focus on some arrows, I noticed that the arrows didn\'t reach the full length between the specified points.

For example:

<         


        
1条回答
  •  北恋
    北恋 (楼主)
    2021-01-24 23:00

    shrinkA=0 and shrinkB=0

    This is the first main direct reason why arrows don't touch.

    Those values default to 2, presumably because arrows were originally mostly used in annotations where some space is desired.

    If I set them to zero:

    FancyArrowPatch(
        shrinkA=0,
        shrinkB=0,
    

    then the arrows touch as shown at:

    A is for the start, and B is for the end of the arrow.

    The effect of linewidth

    Another thing to keep in mind however is that the linewidth can also affect if the arrow touches something or not.

    For example, if I add an exaggerated linewidth=10 to the original code:

    FancyArrowPatch(
        shrinkA=0,
        shrinkB=0,
        linewidth=10,
    

    then the result is:

    so we note how:

    • the tracing of the edges is always rounded, and therefore the arrows stop being pointy and become rounded with large line widths
    • Simple and CurveFilledAB have different drawing algorithms: the one for Simple makes the arrow overrun the target, and CurveFilledAB makes it under run
    • the linewidth above was so fat that it hid the red inner color

    For the case of Simple, if you don't need a different border color, you can get back the pointy arrow with linewidth=0, and control the main arrow line width with tail_width.

    This does not work for CurveFilledAB however: the drawing algorithm for that style is to use the border alone for the main arrow line, so I'm not sure how to separately control the main line width of a double headed arrow without getting the rounded corners, except for drawing two simple arrows which is uglier: matplotlib simple and two head arrows Seems like something that could be patched by adding a new SimpleAB class.

    The result of:

    FancyArrowPatch(
        shrinkA=0,
        shrinkB=0,
        linewidth=0,
    

    is:

    0 讨论(0)
提交回复
热议问题