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

Addresses issue #24618 "Road sign" boxstyle/annotation#24697

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

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
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
56 changes: 41 additions & 15 deletionslib/matplotlib/patches.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2372,14 +2372,19 @@ def __call__(self, x0, y0, width, height, mutation_size):
class LArrow:
"""A box in the shape of a left-pointing arrow."""

def __init__(self, pad=0.3):
def __init__(self, pad=0.3, fhead=False):
"""
Parameters
----------
pad : float, default: 0.3
The amount of padding around the original box.

fhead : bool, default: False
If the arrowheads should be flush with the top
and botton sides of the arrow body.
"""
self.pad = pad
self.fhead = fhead

def __call__(self, x0, y0, width, height, mutation_size):
# padding
Expand All@@ -2394,11 +2399,17 @@ def __call__(self, x0, y0, width, height, mutation_size):
dxx = dx / 2
x0 = x0 + pad / 1.4 # adjust by ~sqrt(2)

return Path._create_closed(
[(x0 + dxx, y0), (x1, y0), (x1, y1), (x0 + dxx, y1),
(x0 + dxx, y1 + dxx), (x0 - dx, y0 + dx),
(x0 + dxx, y0 - dxx), # arrow
(x0 + dxx, y0)])
if self.fhead:
return Path._create_closed([(x0 + dxx - pad, y0), (x1, y0),
(x1, y1), (x0 + dxx - pad, y1),
(x0 - dx - pad, y0 + dx),
(x0 + dxx - pad, y0)])

return Path._create_closed([(x0 + dxx, y0), (x1, y0), (x1, y1),
(x0 + dxx, y1), (x0 + dxx, y1 + dxx),
(x0 - dx, y0 + dx),
(x0 + dxx, y0 - dxx), # arrow
(x0 + dxx, y0), (x0 + dxx, y0)])

@_register_style(_style_list)
class RArrow(LArrow):
Expand All@@ -2415,14 +2426,19 @@ class DArrow:
"""A box in the shape of a two-way arrow."""
# Modified from LArrow to add a right arrow to the bbox.

def __init__(self, pad=0.3):
def __init__(self, pad=0.3, fhead=False):
"""
Parameters
----------
pad : float, default: 0.3
The amount of padding around the original box.

fhead : bool, default: False
If the arrowheads should be flush with the top
and botton sides of the arrow body.
"""
self.pad = pad
self.fhead = fhead

def __call__(self, x0, y0, width, height, mutation_size):
# padding
Expand All@@ -2438,14 +2454,24 @@ def __call__(self, x0, y0, width, height, mutation_size):
dxx = dx / 2
x0 = x0 + pad / 1.4 # adjust by ~sqrt(2)

return Path._create_closed([
(x0 + dxx, y0), (x1, y0), # bot-segment
(x1, y0 - dxx), (x1 + dx + dxx, y0 + dx),
(x1, y1 + dxx), # right-arrow
(x1, y1), (x0 + dxx, y1), # top-segment
(x0 + dxx, y1 + dxx), (x0 - dx, y0 + dx),
(x0 + dxx, y0 - dxx), # left-arrow
(x0 + dxx, y0)])
if self.fhead:
return Path._create_closed([(x0 + dxx - pad, y0),
(x1 + pad, y0),
(x1 + dx + dxx + pad, y0 + dx),
(x1 + pad, y1),
(x0 + dxx - pad, y1),
(x0 - dx - pad, y0 + dx),
(x0 + dxx - pad, y0)])

return Path._create_closed([(x0 + dxx, y0), (x1, y0),
(x1, y0 - dxx),
(x1 + dx + dxx, y0 + dx),
(x1, y1 + dxx), # right-arrow
(x1, y1), (x0 + dxx, y1),
(x0 + dxx, y1 + dxx),
(x0 - dx, y0 + dx),
(x0 + dxx, y0 - dxx), # left-arrow
(x0 + dxx, y0)])

@_register_style(_style_list)
class Round:
Expand Down
10 changes: 5 additions & 5 deletionstutorials/text/annotations.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -192,10 +192,10 @@
# Class Name Attrs
# ========== ============== ==========================
# Circle ``circle`` pad=0.3
# DArrow ``darrow`` pad=0.3
# DArrow ``darrow`` pad=0.3,fhead=False
# Ellipse ``ellipse`` pad=0.3
# LArrow ``larrow`` pad=0.3
# RArrow ``rarrow`` pad=0.3
# LArrow ``larrow`` pad=0.3,fhead=False
# RArrow ``rarrow`` pad=0.3,fhead=False
# Round ``round`` pad=0.3,rounding_size=None
# Round4 ``round4`` pad=0.3,rounding_size=None
# Roundtooth ``roundtooth`` pad=0.3,tooth_size=None
Expand All@@ -215,12 +215,12 @@
# (facecolor, edgewidth, etc.) can be accessed and modified as usual.
# `.FancyBboxPatch.set_boxstyle` sets the box shape::
#
# bb.set_boxstyle("rarrow", pad=0.6)
# bb.set_boxstyle("rarrow", pad=0.6, fhead=True)
#
# The attribute arguments can also be specified within the style
# name with separating comma::
#
# bb.set_boxstyle("rarrow, pad=0.6")
# bb.set_boxstyle("rarrow, pad=0.6, fhead=True")
#
#
# Defining custom box styles
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp