-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
I agree that one should probably not copy the
? As these properties are explicit in the constructor. ( Turns out that Anyway, no strong opinions as such (I can always add those later), but I'll leave it for a while to see if someone has stronger opinions. |
Now I look deeper, I think having "Other parameters are identical to Annotation" next to |
78307ab
to
59abe41
Compare
I think I have addressed all the comments, but... What text does this |
Looking into the code, the fontsize parameter is stored in a AFAICS we should rename |
I didn't really look at what piece of code you're talking about (can you point out the line?) but I was certainly not involved with matplotlib development yet in 2009... |
I think matplotlib/lib/matplotlib/offsetbox.py Lines 1296 to 1305 in 1fa7467
|
Sorry, mixed up users. - Just read the short version "09.08.09 Lee", but it was @leejjoon. @leejjoon do you rember the motivation in matplotlib/lib/matplotlib/offsetbox.py Line 1235 in 1fa7467
matplotlib/lib/matplotlib/offsetbox.py Lines 1348 to 1358 in 1fa7467
matplotlib/lib/matplotlib/offsetbox.py Lines 1296 to 1302 in 1fa7467
it indeed seems that |
I guess using So perhaps using Edit: AnchoredOffsetbox does something similar with the |
59abe41
to
426b189
Compare
My vague recollection is that I wanted to copy the behavior from annotation (and text) that the mutation scale is set to their fontsize. As @rcomer commented in his post, I think this was a sensible thing to do. The parameter name of |
@timhoffm I have updated the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timhoffm I have updated the
fontsize
description to explain how it is used. Do you think this is enough? Once we understand the reasoning, the name does not seem wrong to me. Perhaps a little unintuitive, but I wonder if that matters enough to go through the breaking change procedure.
I still think the name is misleading because it does not affect any font. It only happens to be that mutation_scale is defined in such a way that setting mutation_scale to the used fontsize gives a reasonable scaling (e.g. for pad). That could also be done with an explicit name mutation_scale, including supporting string values.
That said, I would not name it like this again, but I'm not dogmatic about changing the name. When we have at least documented what the parameter is about that's already a big improvement. But if we keep the name AnnotationBbox.set_fontsize
needs a similar description.
lib/matplotlib/offsetbox.py
Outdated
@@ -1262,6 +1262,11 @@ 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. see `.Annotation` for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to copy the whole description from Annotation. It's not likely to change, and there is value in having the explicit value description here. Not least because the docstring of Annotation is long and it's a bit cumbersome to find the relevant section.
lib/matplotlib/offsetbox.py
Outdated
`.FancyBboxPatch` to scale attributes of the box style (e.g. pad | ||
or rounding_size). Passed here as *fontsize* for the convenience | ||
of using the named sizes. If not given, :rc:`legend.fontsize` is | ||
used. See `~.Text.set_fontsize` for valid values. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used. See `~.Text.set_fontsize` for valid values. | |
used. See `.Text.set_fontsize` for valid values. |
so that it renders as Text.set_fontsize
and not set_fontsize
and by that make it very clear that its not
AnnotationBbox.set_fontsize`.
lib/matplotlib/offsetbox.py
Outdated
or rounding_size). Passed here as *fontsize* for the convenience | ||
of using the named sizes. If not given, :rc:`legend.fontsize` is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or rounding_size). Passed here as *fontsize* for the convenience | |
of using the named sizes. If not given, :rc:`legend.fontsize` is | |
or rounding_size). If not given, :rc:`legend.fontsize` is |
I'd leave this out. I think it's not really helpful for understanding (or even technically necessary to provide the convenience).
If you want to comment on the name, it should be more in the direction
the name is chosen in analogy to [...*] where fontsize defines the mutation scale as well.
* To be checked what exactly: Text/Annotation/Legend/FancyBboxPatch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it's in Text
matplotlib/lib/matplotlib/text.py
Line 582 in 57710db
self._bbox_patch.set_mutation_scale(fontsize_in_pixel) |
lib/matplotlib/offsetbox.py
Outdated
**kwargs | ||
Other parameters are identical to `.Annotation`. | ||
Other `AnnotationBbox` properties. See `~.AnnotationBbox.set` for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other `AnnotationBbox` properties. See `~.AnnotationBbox.set` for | |
Other `AnnotationBbox` properties. See `.AnnotationBbox.set` for |
Minor, but I think it's slightly better to display the class here as well.
426b189
to
390b277
Compare
Thanks @rcomer! I appreciate this work. It's often more cumbersome than initially expected, but it really makes our docs much better. |
…444-on-v3.6.x Backport PR #24444 on branch v3.6.x (DOC: AnnotationBbox keyword descriptions)
PR Summary
Closes #24390.
bboxprops
keyword forAnnotationBbox
instantiation. At [Doc]: alpha setting for annotationTextArea
#24390 (comment) @oscargus noted thatarrowprops
andfontsize
are also missing from the docstring, but possibly they are covered by "Other parameters are identical to Annotation"? I note that thearrowprops
description in Annotation is quite extensive, so am not sure of the wisdom of copying it across to related docstrings.bboxprops
keyword.While I was in there I also changed all double quotes to single quotes, as there is currently a mixture and I think it should be consistent within the example.PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst