FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow tuning the shape of {L,R,D}Arrow tips. by anntzer · Pull Request #31198 · matplotlib/matplotlib · GitHub

Repository navigation

Allow tuning the shape of {L,R,D}Arrow tips. - #31198

Merged
QuLogic merged 3 commits into
matplotlib:mainfrom
anntzer:roadsign
Mar 27, 2026
Merged

QuLogic merged 3 commits into
matplotlib:mainfrom
anntzer:roadsign

Conversation

anntzer commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

PR summary

Implements the "road sign" arrows requested at #24618 (closes #24618). The implementation is the one suggested at #29998 (comment) (with some tweaks, especially in the obtuse reverse arrow case), so that the shape varies continuously with the parameters. To acknowledge the original PR authors I've squashed their commits and kept them as respective authors of a docs commit (extracted from #24744) and a test commit (directly taken from #29998, although the baseline image is actually different).

@QuLogic's interactive test script is reproduced below for convenience:

import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from matplotlib.widgets import Slider

fig, ax = plt.subplots(3, 1, height_ratios=[4, 1, 1])

texts = []
for i, arrow in enumerate(['larrow', 'rarrow', 'darrow']):
    texts.append(
        ax[0].text(0.5, 0.3*i + 0.2, 'Arrow', ha='center', size=16,
                   bbox=dict(boxstyle=f"{arrow}, pad=0.3, head_angle=150")))


def update_head_angle(value):
    for t in texts:
        t.get_bbox_patch().get_boxstyle().head_angle = value
    fig.canvas.draw_idle()


def update_head_width(value):
    for t in texts:
        t.get_bbox_patch().get_boxstyle().head_width = value
    fig.canvas.draw_idle


angle_slider = Slider(ax[1], 'Angle', 0, 360, valinit=150, closedmin=False)
angle_slider.on_changed(update_head_angle)

width_slider = Slider(ax[2], 'Width', 0, 3, valinit=1.5)
width_slider.on_changed(update_head_width)

plt.show()

PR checklist

github-actions Bot added the Documentation: user guide files in galleries/users_explain or doc/users label Feb 25, 2026
anntzer force-pushed the roadsign branch 2 times, most recently from f0a6cf3 to d65b419 Compare February 25, 2026 10:35
The new *head_width* and *head_angle* parameters to
`.BoxStyle.LArrow`, `.BoxStyle.RArrow` and `.BoxStyle.DArrow` allow for adjustment
of the size and aspect ratio of the arrow heads used.

timhoffm Feb 26, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
To give a consistent appearance across all parameter values, the
default head position (where the head starts relative to text) is
slightly changed compared to the previous hard-coded position.

timhoffm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We could have a more in-depth example on how the parameters work. The what's new entry is the only visualization and it's not discoverable from the Arrow docs.

But that can also come later.

Comment thread lib/matplotlib/patches.py Outdated

anntzer commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

thanks, fixed. I'll skip on the extra docs :)

Comment thread lib/matplotlib/patches.pyi Outdated

QuLogic commented Mar 27, 2026 •
edited
Loading

Copy link
Copy Markdown
Member

You'll need to rebase to get docs to run properly (also CI has been fixed.)

anntzer and others added 3 commits March 27, 2026 10:49

anntzer commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

rebased

QuLogic merged commit 49fd492 into matplotlib:main Mar 27, 2026
39 of 41 checks passed
anntzer deleted the roadsign branch March 27, 2026 18:48
QuLogic mentioned this pull request Mar 27, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation: user guide files in galleries/users_explain or doc/users topic: annotation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH]: "Road sign" boxstyle/annotation

5 participants


Back | FazBrowse Home | New Git URL