8000 DOC: Improve FancyArrowPatch docstring · matplotlib/matplotlib@8596a8d · GitHub
[go: up one dir, main page]

Skip to content
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

Appearance settings

Commit 8596a8d

Browse files
committed
DOC: Improve FancyArrowPatch docstring
1 parent 33dbc47 commit 8596a8d

File tree

1 file changed

+64
-23
lines changed

1 file changed

+64
-23
lines changed

lib/matplotlib/patches.py

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,7 +2358,7 @@ def get_styles(cls):
23582358
@classmethod
23592359
def pprint_styles(cls):
23602360
"""Return the available styles as pretty-printed string."""
2361-
table = [('Class', 'Name', 'Attrs'),
2361+
table = [('Class', 'Name', 'Parameters'),
23622362
*[(cls.__name__,
23632363
# Add backquotes, as - and | have special meaning in reST.
23642364
f'``{name}``',
@@ -4182,49 +4182,90 @@ def __init__(self, posA=None, posB=None, *,
41824182
patchA=None, patchB=None, shrinkA=2, shrinkB=2,
41834183
mutation_scale=1, mutation_aspect=1, **kwargs):
41844184
"""
4185-
There are two ways for defining an arrow:
4185+
**Defining the arrow position and path**
41864186
4187-
- If *posA* and *posB* are given, a path connecting two points is
4188-
created according to *connectionstyle*. The path will be
4189-
clipped with *patchA* and *patchB* and further shrunken by
4190-
*shrinkA* and *shrinkB*. An arrow is drawn along this
4191-
resulting path using the *arrowstyle* parameter.
4187+
There are two ways to define the arrow position and path:
41924188
4193-
- Alternatively if *path* is provided, an arrow is drawn along this
4194-
path and *patchA*, *patchB*, *shrinkA*, and *shrinkB* are ignored.
4189+
- **Start, end and connection**:
4190+
The typical approach is to define the start and end points of the
4191+
arrow using *posA* and *posB*. The curve between these two can
4192+
further be configured using *connectionstyle*.
4193+
4194+
If given, the arrow curve is clipped by *patchA* and *patchB*,
4195+
allowing it to start/end at the border of these patches.
4196+
Additionally, the arrow curve can be shortened by *shrinkA* and *shrinkB*
4197+
to create a margin between start/end (after possible clipping) and the
4198+
drawn arrow.
4199+
4200+
- **path**: Alternatively if *path* is provided, an arrow is drawn along
4201+
this Path. In this case, *connectionstyle*, *patchA*, *patchB*,
4202+
*shrinkA*, and *shrinkB* are ignored.
4203+
4204+
**Styling**
4205+
4206+
The *arrowstyle* defines the styling of the arrow head, tail and shaft.
4207+
The resulting arrows can be styled further by setting the `.Patch`
4208+
properties such as *linewidth*, *color*, *facecolor*, *edgecolor*
4209+
etc. via keyword arguments.
41954210
41964211
Parameters
41974212
----------
4198-
posA, posB : (float, float), default: None
4199-
(x, y) coordinates of arrow tail and arrow head respectively.
4213+
posA, posB : (float, float), optional
4214+
(x, y) coordinates of start and end point of the arrow.
4215+
The actually drawn start and end positions may be modified
4216+
through *patchA*, *patchB*, *shrinkA*, and *shrinkB*.
42004217
4201-
path : `~matplotlib.path.Path`, default: None
4218+
*posA*, *posB* are exclusive of *path*.
4219+
4220+
path : `~matplotlib.path.Path`, optional
42024221
If provided, an arrow is drawn along this path and *patchA*,
42034222
*patchB*, *shrinkA*, and *shrinkB* are ignored.
42044223
4224+
*path* is exclusive of *posA*, *posB*.
4225+
42054226
arrowstyle : str or `.ArrowStyle`, default: 'simple'
4206-
The `.ArrowStyle` with which the fancy arrow is drawn. If a
4207-
string, it should be one of the available arrowstyle names, with
4208-
optional comma-separated attributes. The optional attributes are
4209-
meant to be scaled with the *mutation_scale*. The following arrow
4210-
styles are available:
4227+
The styling of arrow head, tail and shaft. This can be
4228+
4229+
- `.ArrowStyle` or one of its subclasses
4230+
- The shorthand string name (e.g. "->") as given in the table below,
4231+
optionally containing a comma-separated list of style parameters,
4232+
e.g. "->, head_length=10, head_width=5".
4233+
4234+
The style parameters are scaled by *mutation_scale*.
4235+
4236+
The following arrow styles are available. See also
4237+
:doc:`/gallery/text_labels_and_annotations/fancyarrow_demo`.
42114238
42124239
%(ArrowStyle:table)s
42134240
4241+
Only the styles ``<|-``, ``-|>``, ``<|-|>`` ``simple``, ``fancy``
4242+
and ``wedge`` contain closed paths and can be filled.
4243+
42144244
connectionstyle : str or `.ConnectionStyle` or None, optional, \
42154245
default: 'arc3'
4216-
The `.ConnectionStyle` with which *posA* and *posB* are connected.
4217-
If a string, it should be one of the available connectionstyle
4218-
names, with optional comma-separated attributes. The following
4219-
connection styles are available:
4246+
`.ConnectionStyle` with which *posA* and *posB* are connected.
4247+
This can be
4248+
4249+
- `.ConnectionStyle` or one of its subclasses
4250+
- The shorthand string name as given in the table below, e.g. "arc3".
42204251
42214252
%(ConnectionStyle:table)s
42224253
4254+
Ignored if *path* is provided.
4255+
42234256
patchA, patchB : `~matplotlib.patches.Patch`, default: None
4224-
Head and tail patches, respectively.
4257+
Optional Patches at *posA* and *posB*, respectively. If given,
4258+
the arrow path is clipped by these patches such that head and tail
4259+
are at the border of the patches.
4260+
4261+
Ignored if *path* is provided.
42254262
42264263
shrinkA, shrinkB : float, default: 2
4227-
Shrink amount, in points, of the tail and head of the arrow respectively.
4264+
Shorten the arrow path at *posA* and *posB* by this amount in points.
4265+
This allows to add a margin between the intended start/end points and
4266+
the arrow.
4267+
4268+
Ignored if *path* is provided.
42284269
42294270
mutation_scale : float, default: 1
42304271
Value with which attributes of *arrowstyle* (e.g., *head_length*)

0 commit comments

Comments
 (0)
0