Skip to content

Implement head resizing (and reversal) for larrow/rarrow/darrow #29998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

CharlieThornton33
Copy link

@CharlieThornton33 CharlieThornton33 commented May 1, 2025

PR summary

When creating an annotation using boxed text in an arrow shape (patches.BoxStyle.LArrow/RArrow/DArrow), head_width and head_angle arguments may now be passed to adjust the size of the arrow head(s), and (via the use of negative angles) generate 'reversed' arrow heads. Addresses #24618 and is a direct continuation of @Abitamim's work in #24744.

This solves both the issue initially mentioned in #24618 (creating a pentagonal 'road-sign' annotation box), as well as allowing for many other customisation options for arrows; for example, a reversed-head DArrow could act as a way to bring attention to a certain region on an axis.

import matplotlib.pyplot as plt

fig, ax = plt.subplots(figsize=(4, 3))

t1 = ax.text(0.5, 0.75, "Road-sign",
            ha="center", va="center", size=15,
            bbox=dict(boxstyle="rarrow,pad=0.3,head_width=1,head_angle=45",
                      fc="lightblue", ec="steelblue", lw=2))

t2 = ax.text(0.5, 0.25, "  Reversed heads   ",
            ha="center", va="center", size=15,
            bbox=dict(boxstyle="darrow,pad=0.3,head_width=1.5,head_angle=-45",
                      fc="lightblue", ec="steelblue", lw=2))

plt.show()

pr_example

A new test, test_boxarrow_adjustment, has been added to test these options.

PR checklist

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ENH]: "Road sign" boxstyle/annotation
2 participants