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

Commitb8592f9

Browse files
committed
Add road-sign-annotation option
1 parent00ec4ec commitb8592f9

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

‎lib/matplotlib/patches.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,14 +2372,19 @@ def __call__(self, x0, y0, width, height, mutation_size):
23722372
classLArrow:
23732373
"""A box in the shape of a left-pointing arrow."""
23742374

2375-
def__init__(self,pad=0.3):
2375+
def__init__(self,pad=0.3,fhead=False):
23762376
"""
23772377
Parameters
23782378
----------
23792379
pad : float, default: 0.3
23802380
The amount of padding around the original box.
2381+
2382+
fhead : bool, default: False
2383+
If the arrowheads should be flush with the top
2384+
and botton sides of the arrow body.
23812385
"""
23822386
self.pad=pad
2387+
self.fhead=fhead
23832388

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

2397-
returnPath._create_closed(
2398-
[(x0+dxx,y0), (x1,y0), (x1,y1), (x0+dxx,y1),
2399-
(x0+dxx,y1+dxx), (x0-dx,y0+dx),
2400-
(x0+dxx,y0-dxx),# arrow
2401-
(x0+dxx,y0)])
2402+
ifself.fhead:
2403+
returnPath._create_closed([(x0+dxx-pad,y0), (x1,y0),
2404+
(x1,y1), (x0+dxx-pad,y1),
2405+
(x0-dx-pad,y0+dx),
2406+
(x0+dxx-pad,y0)])
2407+
2408+
returnPath._create_closed([(x0+dxx,y0), (x1,y0), (x1,y1),
2409+
(x0+dxx,y1), (x0+dxx,y1+dxx),
2410+
(x0-dx,y0+dx),
2411+
(x0+dxx,y0-dxx),# arrow
2412+
(x0+dxx,y0), (x0+dxx,y0)])
24022413

24032414
@_register_style(_style_list)
24042415
classRArrow(LArrow):
@@ -2415,14 +2426,19 @@ class DArrow:
24152426
"""A box in the shape of a two-way arrow."""
24162427
# Modified from LArrow to add a right arrow to the bbox.
24172428

2418-
def__init__(self,pad=0.3):
2429+
def__init__(self,pad=0.3,fhead=False):
24192430
"""
24202431
Parameters
24212432
----------
24222433
pad : float, default: 0.3
24232434
The amount of padding around the original box.
2435+
2436+
fhead : bool, default: False
2437+
If the arrowheads should be flush with the top
2438+
and botton sides of the arrow body.
24242439
"""
24252440
self.pad=pad
2441+
self.fhead=fhead
24262442

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

2441-
returnPath._create_closed([
2442-
(x0+dxx,y0), (x1,y0),# bot-segment
2443-
(x1,y0-dxx), (x1+dx+dxx,y0+dx),
2444-
(x1,y1+dxx),# right-arrow
2445-
(x1,y1), (x0+dxx,y1),# top-segment
2446-
(x0+dxx,y1+dxx), (x0-dx,y0+dx),
2447-
(x0+dxx,y0-dxx),# left-arrow
2448-
(x0+dxx,y0)])
2457+
ifself.fhead:
2458+
returnPath._create_closed([(x0+dxx-pad,y0),
2459+
(x1+pad,y0),
2460+
(x1+dx+dxx+pad,y0+dx),
2461+
(x1+pad,y1),
2462+
(x0+dxx-pad,y1),
2463+
(x0-dx-pad,y0+dx),
2464+
(x0+dxx-pad,y0)])
2465+
2466+
returnPath._create_closed([(x0+dxx,y0), (x1,y0),
2467+
(x1,y0-dxx),
2468+
(x1+dx+dxx,y0+dx),
2469+
(x1,y1+dxx),# right-arrow
2470+
(x1,y1), (x0+dxx,y1),
2471+
(x0+dxx,y1+dxx),
2472+
(x0-dx,y0+dx),
2473+
(x0+dxx,y0-dxx),# left-arrow
2474+
(x0+dxx,y0)])
24492475

24502476
@_register_style(_style_list)
24512477
classRound:

‎tutorials/text/annotations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@
192192
# Class Name Attrs
193193
# ========== ============== ==========================
194194
# Circle ``circle`` pad=0.3
195-
# DArrow ``darrow`` pad=0.3
195+
# DArrow ``darrow`` pad=0.3,fhead=False
196196
# Ellipse ``ellipse`` pad=0.3
197-
# LArrow ``larrow`` pad=0.3
198-
# RArrow ``rarrow`` pad=0.3
197+
# LArrow ``larrow`` pad=0.3,fhead=False
198+
# RArrow ``rarrow`` pad=0.3,fhead=False
199199
# Round ``round`` pad=0.3,rounding_size=None
200200
# Round4 ``round4`` pad=0.3,rounding_size=None
201201
# Roundtooth ``roundtooth`` pad=0.3,tooth_size=None
@@ -215,12 +215,12 @@
215215
# (facecolor, edgewidth, etc.) can be accessed and modified as usual.
216216
# `.FancyBboxPatch.set_boxstyle` sets the box shape::
217217
#
218-
# bb.set_boxstyle("rarrow", pad=0.6)
218+
# bb.set_boxstyle("rarrow", pad=0.6, fhead=True)
219219
#
220220
# The attribute arguments can also be specified within the style
221221
# name with separating comma::
222222
#
223-
# bb.set_boxstyle("rarrow, pad=0.6")
223+
# bb.set_boxstyle("rarrow, pad=0.6, fhead=True")
224224
#
225225
#
226226
# Defining custom box styles

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp