Skip to content

annotation connectionstyle and width, headwidth compatibility issue #14195

Closed

Description

@jiadongdan

Some connectionstyle can not work!!!

See code below:

fig, ax = plt.subplots(1, 1, figsize=(7.2, 7.2))
start = (0.1, 0.1)
end = (0.5, 0.5)
connectionstyle='arc3, rad=1'
#connectionstyle='angle,angleA=-90,angleB=10,rad=5' #this not working

ax.annotate("",
            xy=end, xycoords='data',
            xytext=start, textcoords='data',
            arrowprops=dict(#arrowstyle="->, head_length=1, head_width=1",
                            width=10,headwidth=30,
                            color="0.5",
                            shrinkA=5, shrinkB=5,
                            patchA=None,
                            patchB=None,
                            connectionstyle=connectionstyle,
                            ),)

This code snipet works fine. However, if I change connectionstyle to "angle,angleA=-90,angleB=10,rad=5", it just does not work. Not sure what is wrong.

matplotlib version: 3.0.3

Activity

  1. jklymak commented on May 12, 2019

    @jklymak
    Member
    Traceback (most recent call last):
      File "/Users/jklymak/matplotlib/lib/matplotlib/backends/backend_qt5.py", line 501, in _draw_idle
        self.draw()
      File "/Users/jklymak/matplotlib/lib/matplotlib/backends/backend_agg.py", line 388, in draw
        self.figure.draw(self.renderer)
      File "/Users/jklymak/matplotlib/lib/matplotlib/artist.py", line 38, in draw_wrapper
        return draw(artist, renderer, *args, **kwargs)
      File "/Users/jklymak/matplotlib/lib/matplotlib/figure.py", line 1716, in draw
        renderer, self, artists, self.suppressComposite)
      File "/Users/jklymak/matplotlib/lib/matplotlib/image.py", line 135, in _draw_list_compositing_images
        a.draw(renderer)
      File "/Users/jklymak/matplotlib/lib/matplotlib/artist.py", line 38, in draw_wrapper
        return draw(artist, renderer, *args, **kwargs)
      File "/Users/jklymak/matplotlib/lib/matplotlib/axes/_base.py", line 2670, in draw
        mimage._draw_list_compositing_images(renderer, self, artists)
      File "/Users/jklymak/matplotlib/lib/matplotlib/image.py", line 135, in _draw_list_compositing_images
        a.draw(renderer)
      File "/Users/jklymak/matplotlib/lib/matplotlib/artist.py", line 38, in draw_wrapper
        return draw(artist, renderer, *args, **kwargs)
      File "/Users/jklymak/matplotlib/lib/matplotlib/text.py", line 2369, in draw
        self.arrow_patch.draw(renderer)
      File "/Users/jklymak/matplotlib/lib/matplotlib/patches.py", line 4303, in draw
        path, fillable = self.get_path_in_displaycoord()
      File "/Users/jklymak/matplotlib/lib/matplotlib/patches.py", line 4287, in get_path_in_displaycoord
        self.get_mutation_aspect())
      File "/Users/jklymak/matplotlib/lib/matplotlib/patches.py", line 3250, in __call__
        return self.transmute(path, mutation_size, linewidth)
      File "/Users/jklymak/matplotlib/lib/matplotlib/patches.py", line 3717, in transmute
        x0, y0, x1, y1, x2, y2 = self.ensure_quadratic_bezier(path)
      File "/Users/jklymak/matplotlib/lib/matplotlib/patches.py", line 3202, in ensure_quadratic_bezier
        "'path' is not a valid quadratic Bezier curve")
    ValueError: 'path' is not a valid quadratic Bezier curve
    
  2. github-actions commented on Jun 16, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  3. ksunden commented on Jun 16, 2023

    @ksunden
    Member

    I think that this is actually correct that it is unable to work and should raise, however I think the work is to make the error message more understandable (and potentially erroring before draw is called, but that is less necessary). While "not a valid quadratic Bezier curve" is at least in some sense accurate and the proximal cause of the incompatibility, it is not useful to a user who asked for an arrow to be drawn.

    The short version is that the default arrow style is "simple", which can only work with a subset of connection styles, such as arc3 or angle3.

    Setting the arrow style to e.g. -> (or pretty much any of the more pictoral keys, i.e. all except "simple", "fancy", or "wedge") will fix it.

    The annotate docstring for the arrowprops arg gets at this behavior by saying:

    For historical reasons there are two different ways to specify arrows, "simple" and "fancy":

    Simple arrow:

    If arrowprops does not contain the key 'arrowstyle' the allowed keys are:

    <table removed for brevity, but notably "connectionstyle" is absent>

    ...

    Fancy arrow:

    This is used if 'arrowstyle' is provided in the arrowprops.

    Valid keys are the following FancyArrowPatch parameters:

    <table removed for brevity, but notably "connectionstyle" is present>

    Technically, there are some options for "connectionstyle" that will work, and they do still get passed through to FancyArrowPatch so not sure disallowing it fully would be advisable.

  4. github-actions commented on Sep 1, 2025

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  5. added
    keepItems to be ignored by the “Stale” Github Action
    on Sep 1, 2025
  6. timhoffm commented on Sep 2, 2025

    @timhoffm
    Member

    The updated docstring that @ksunden mentions has been added in #21743, so after this issue was created. I consider the issue solved through that PR.

  7. removed
    status: inactiveMarked by the “Stale” Github Action
    keepItems to be ignored by the “Stale” Github Action
    on Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions