Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC: AnnotationBbox keyword descriptions #24444

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 6 additions & 4 deletions examples/text_labels_and_annotations/demo_annotation_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
xybox=(-20, 40),
xycoords='data',
boxcoords="offset points",
arrowprops=dict(arrowstyle="->"))
arrowprops=dict(arrowstyle="->"),
bboxprops=dict(boxstyle="sawtooth"))
ax.add_artist(ab)

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

ab = AnnotationBbox(da, xy,
xybox=(1.02, xy[1]),
xybox=(1., xy[1]),
xycoords='data',
boxcoords=("axes fraction", "data"),
box_alignment=(0., 0.5),
arrowprops=dict(arrowstyle="->"))
box_alignment=(0.2, 0.5),
arrowprops=dict(arrowstyle="->"),
bboxprops=dict(alpha=0.5))

ax.add_artist(ab)

Expand Down
29 changes: 28 additions & 1 deletion lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,16 @@ def __init__(self, offsetbox, xy,
(accessible as the ``patch`` attribute of the `.AnnotationBbox`).
If *frameon* is set to False, this patch is made invisible.

annotation_clip: bool or None, default: None
Whether to clip (i.e. not draw) the annotation when the annotation
point *xy* is outside the axes area.

- If *True*, the annotation will be clipped when *xy* is outside
the axes.
- If *False*, the annotation will always be drawn.
- If *None*, the annotation will be clipped when *xy* is outside
the axes and *xycoords* is 'data'.

pad : float, default: 0.4
Padding around the offsetbox.

Expand All @@ -1270,8 +1280,25 @@ def __init__(self, offsetbox, xy,
the offset box w.r.t. the *boxcoords*.
The lower-left corner is (0, 0) and upper-right corner is (1, 1).

bboxprops : dict, optional
A dictionary of properties to set for the annotation bounding box,
for example *boxstyle* and *alpha*. See `.FancyBboxPatch` for
details.

arrowprops: dict, optional
Arrow properties, see `.Annotation` for description.

fontsize: float or str, optional
Translated to points and passed as *mutation_scale* into
`.FancyBboxPatch` to scale attributes of the box style (e.g. pad
or rounding_size). The name is chosen in analogy to `.Text` where
*fontsize* defines the mutation scale as well. If not given,
:rc:`legend.fontsize` is used. See `.Text.set_fontsize` for valid
values.

**kwargs
Other parameters are identical to `.Annotation`.
Other `AnnotationBbox` properties. See `.AnnotationBbox.set` for
a list.
"""

martist.Artist.__init__(self)
Expand Down