Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
CharlieThornton33 wants to merge38 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromCharlieThornton33:road-sign-annotation
Open
Changes from1 commit
Commits
Show all changes
38 commits
Select commitHold shift + click to select a range
2f366fa
Make arrow annotation arrowhead adjustable
AbitamimDec 16, 2022
e8d7eb7
Add test - not sure if correct
AbitamimDec 16, 2022
15bd7dc
Update tutorial
AbitamimDec 16, 2022
4f57495
Fixed linting
AbitamimDec 16, 2022
5c3fa60
Add reversed arrow-head support to larrow/rarrow
CharlieThornton33Apr 17, 2025
8065549
Fix reversed arrow-head support for single arrows, handle edge cases
CharlieThornton33Apr 20, 2025
0471e92
Add support for reversed arrow-heads and edge cases in DArrow, update…
CharlieThornton33Apr 20, 2025
212cbc9
Update docstings, add what's new notes
CharlieThornton33Apr 22, 2025
273a2fe
Fix typo in DArrow drawing code
CharlieThornton33Apr 28, 2025
bf2d06b
Fixed padding inconsistency: reverted breaking API change
CharlieThornton33Apr 28, 2025
0ea2f5a
Fix what's new example
CharlieThornton33Apr 28, 2025
d7fd405
Create unit test for boxarrow head adjustment
CharlieThornton33Apr 30, 2025
ff34b4b
Fixed linting
CharlieThornton33Apr 30, 2025
d9b0b32
Update new test to use mpl20 figure style
CharlieThornton33May 1, 2025
f3369c0
Changed padding for LArrow/RArrow to prevent text spilling out
CharlieThornton33May 14, 2025
3913ef6
[skip ci] Fix spelling mistake in LArrow padding code
CharlieThornton33May 14, 2025
63a4ba9
Remove 'poking-out' behaviour from reversed arrow-heads, add padding …
CharlieThornton33Jun 19, 2025
7ed9fd1
Remove now-unneeded manual padding from What's New page
CharlieThornton33Jun 19, 2025
d953aef
Remove test_boxarrow_adjustment
CharlieThornton33Jun 19, 2025
d2105da
Prevent text overspill from DArrows using padding
CharlieThornton33Jun 19, 2025
54147e6
Added test for arrow-head adjustments
CharlieThornton33Jun 20, 2025
b5ba28e
Fix padding from straight-edges of reversed arrow heads, fix incorrec…
CharlieThornton33Jul 5, 2025
976e54b
[skip ci] Fix indentation in galleries/users_explain/text/annotations.py
CharlieThornton33Jul 9, 2025
a08c67b
[skip ci] Use python % operator rather than np.mod() to act on scalar…
CharlieThornton33Jul 9, 2025
1dc613e
[skip ci] Fix padding for non-reversed small head-size arrows
CharlieThornton33Jul 18, 2025
73d9532
[skip ci] Use += and -= abbreviations
CharlieThornton33Jul 18, 2025
2b83aff
[skip ci] Change layout of vertex array for non-reversed LArrow head …
CharlieThornton33Jul 18, 2025
e94a777
Improve clarity of DArrow padding code
CharlieThornton33Jul 24, 2025
98d4bc4
Make What's New example simpler and more informative
CharlieThornton33Jul 25, 2025
2ac0bff
Implement simplified padding rules
CharlieThornton33Aug 9, 2025
a6e2abf
Fix padding for darrows
CharlieThornton33Sep 9, 2025
f8ba249
Style padding code consistently between larrow and darrow
CharlieThornton33Sep 9, 2025
7b4b3b1
[ci doc] Move what's new page to releases directory
CharlieThornton33Sep 9, 2025
119a051
[skip ci] Make head-width validation clearer
CharlieThornton33Sep 11, 2025
80d1c40
Move head-angle validation into constructor
CharlieThornton33Sep 11, 2025
460306e
Remove references to 'text' for describing original box
CharlieThornton33Sep 11, 2025
201e62c
[skip ci] Fix accidental paste into docstring
CharlieThornton33Sep 11, 2025
94fa82d
Fix nomenclature (arrow tail -> arrow shaft)
CharlieThornton33Sep 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Move head-angle validation into constructor
  • Loading branch information
@CharlieThornton33
CharlieThornton33 committedSep 11, 2025
commit80d1c40361e1159ac34c924c38cfc8d684dba8e4
22 changes: 13 additions & 9 deletionslib/matplotlib/patches.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2531,6 +2531,10 @@ def __init__(self, pad=0.3, head_width=1.5, head_angle=90.0):
# Set arrow-head angle to within [0, 360 deg)
self.head_angle = head_angle % 360.

if self.head_angle == 0:
# This would cause a division by zero ('infinitely long' arrow head)
raise ValueError("Head angle of zero is not valid.")

def __call__(self, x0, y0, width, height, mutation_size):
# scaled padding
pad = mutation_size * self.pad
Expand All@@ -2554,10 +2558,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
# the total 'width' of arrow-head not within the body.
width_adjustment = (self.head_width - 1) * dx

if self.head_angle == 0:
# This would cause a division by zero ('infinitely long' arrow head)
raise ValueError("Head angle of zero is not valid.")
elif self.head_angle <= 180:
if self.head_angle <= 180:
# Non-reversed arrow head (<---)

# tan(1/2 * angle subtended by arrow tip)
Expand DownExpand Up@@ -2659,7 +2660,9 @@ def __init__(self, pad=0.3, head_width=1.5, head_angle=90.0):
The amount of padding around the original box.
head_width : float, default: 1.5
The width of each arrow head, relative to that of the arrow body.
Only positive values are accepted.
Only positive valuesif self.head_angle == 0:
# This would cause a division by zero ('infinitely long' arrow head)
raise ValueError("Head angle of zero is not valid.") are accepted.
head_angle : float, default: 90.0
The angle subtended by the tip of each arrow head, in degrees.
Only nonzero angles are accepted.
Expand All@@ -2674,6 +2677,10 @@ def __init__(self, pad=0.3, head_width=1.5, head_angle=90.0):
# Set arrow-head angle to within [0, 360 deg)
self.head_angle = head_angle % 360.

if self.head_angle == 0:
# This would cause a division by zero ('infinitely long' arrow head)
raise ValueError("Head angle of zero is not valid.")

def __call__(self, x0, y0, width, height, mutation_size):
# scaled padding
pad = mutation_size * self.pad
Expand All@@ -2698,10 +2705,7 @@ def __call__(self, x0, y0, width, height, mutation_size):
# the total 'width' of arrow-head not within the body.
width_adjustment = (self.head_width - 1) * dx

if self.head_angle == 0:
# This would cause a division by zero ('infinitely long' arrow head)
raise ValueError("Head angle of zero is not valid.")
elif self.head_angle <= 180:
if self.head_angle <= 180:
# Non-reversed arrow heads (<--->)

# tan(1/2 * angle subtended by arrow tip)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp