8000 Merge pull request #24444 from rcomer/annotation-doc · matplotlib/matplotlib@a9c9620 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9c9620

Browse files
authored
Merge pull request #24444 from rcomer/annotation-doc
DOC: AnnotationBbox keyword descriptions
2 parents 57710db + 390b277 commit a9c9620

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

examples/text_labels_and_annotations/demo_annotation_box.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
xybox=(-20, 40),
3232
xycoords='data',
3333
boxcoords="offset points",
34-
arrowprops=dict(arrowstyle="->"))
34+
arrowprops=dict(arrowstyle="->"),
35+
bboxprops=dict(boxstyle="sawtooth"))
3536
ax.add_artist(ab)
3637

3738
# Annotate the 1st position with another text box ('Test')
@@ -54,11 +55,12 @@
5455
da.add_artist(p)
5556

5657
ab = AnnotationBbox(da, xy,
57-
xybox=(1.02, xy[1]),
58+
xybox=(1., xy[1]),
5859
xycoords='data',
5960
boxcoords=("axes fraction", "data"),
60-
box_alignment=(0., 0.5),
61-
arrowprops=dict(arrowstyle="->"))
61+
box_alignment=(0.2, 0.5),
62+
arrowprops=dict(arrowstyle="->"),
63+
bboxprops=dict(alpha=0.5))
6264

6365
ax.add_artist(ab)
6466

lib/matplotlib/offsetbox.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,16 @@ def __init__(self, offsetbox, xy,
12571257
(accessible as the ``patch`` attribute of the `.AnnotationBbox`).
12581258
If *frameon* is set to False, this patch is made invisible.
12591259
1260+
annotation_clip: bool or None, default: None
1261+
Whether to clip (i.e. not draw) the annotation when the annotation
1262+
point *xy* is outside the axes area.
1263+
1264+
- If *True*, the annotation will be clipped when *xy* is outside
1265+
the axes.
1266+
- If *False*, the annotation will always be drawn.
1267+
- If *None*, the annotation will be clipped when *xy* is outside
1268+
the axes and *xycoords* is 'data'.
1269+
12601270
pad : float, default: 0.4
12611271
Padding around the offsetbox.
12621272
@@ -1265,8 +1275,25 @@ def __init__(self, offsetbox, xy,
12651275
the offset box w.r.t. the *boxcoords*.
12661276
The lower-left corner is (0, 0) and upper-right corner is (1, 1).
12671277
1278+
bboxprops : dict, optional
1279+
A dictionary of properties to set for the annotation bounding box,
1280+
for example *boxstyle* and *alpha*. See `.FancyBboxPatch` for
1281+
details.
1282+
1283+
arrowprops: dict, optional
1284+
Arrow properties, see `.Annotation` for description.
1285+
1286+
fontsize: float or str, optional
1287+
Translated to points and passed as *mutation_scale* into
1288+
`.FancyBboxPatch` to scale attributes of the box style (e.g. pad
1289+
or rounding_size). The name is chosen in analogy to `.Text` where
1290+
*fontsize* defines the mutation scale as well. If not given,
1291+
:rc:`legend.fontsize` is used. See `.Text.set_fontsize` for valid
1292+
values.
1293+
12681294
**kwargs
1269-
Other parameters are identical to `.Annotation`.
1295+
Other `AnnotationBbox` properties. See `.AnnotationBbox.set` for
1296+
a list.
12701297
"""
12711298

12721299
martist.Artist.__init__(self)

0 commit comments

Comments
 (0)
0