-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify annotation examples. #13515
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
@@ -92,12 +91,11 @@ def doall(): | |||
color=fill_color, alpha=0.5) | |||
plt.annotate(title, | |||
xy=(0.07, baseline - 0.3 * line_axesfrac), | |||
xycoords='data', color=mpl_grey_rvb, weight='bold') |
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 don't think its helpful to drop all the xycoord='data'
calls. Its good for users to understand that there are different co-oridnates that annotate can be expressed in...
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.
But the point is that "data" is the default for annotate() just like it is the default for nearly every other function (e.g. in particular text()).
I purposefully left the xycoords=... in the main annotation demo and tutorials (where the coordinates systems are explained), but outside of them I think these are just noise.
(And again I'd rather have people learn to use ax.transData/ax.transAxes which also works for text(), instead of an annotate()-specific API.)
I would agree to roughly half of the changes made here. Certainly
is better written as
However,
is much better than
In general Removing the
However, in cases which show the functionality of annotations, it adds clear value and points the user to the option to use some other coordinates systems as well. I would hence oppose the changes in
Furthermore at least some of the examples
should keep it. Those are originally part of the annotations guide. It would totally make sense to rework that guide and bring some variety concerning the allowed arguments into it. |
At the risk of sounding like a broken record...
In my view, this means that we should rename
|
The problem is that somehow
For now, I'm not convinced that just ripping all the string-based examples out of the documentation base is the right thing to do until we decide what to do about the API. If both APIs are staying as-is, then I'm not sure this PR is the way to go.... |
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.
Blocking on strategy discussion, not because I think this is a bad idea.
Maybe one can separate between the changes that are a clear improvement of the docs and changes that are controversial? I.e. either remove the offending stuff out of this PR, or open a new PR with the helpful and harmless stuff? |
The "noncontroversial" parts are in #13549. |
When xycoords and textcoords use the default of "data" (which is the same as for text(), for example), don't bother specifying it. In some other cases, I find it clearer to specify xycoords in terms of the more general `ax.transAxes` (i.e. "axes fraction") or `IdentityTransform()` (i.e. "figure pixels"), or even `ax.get_yaxis_transform()` (i.e. `("axes fraction", "data")`) -- transforms are a general, widely used concept, whereas transform strings only apply to annotate().
bd298e9
to
2bf2894
Compare
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
I've changed my mind, the string args can be quite nice to work with in practice. Some other parts of the PR have now been merged separately anyways. |
When xycoords and textcoords use the default of "data" (which is the
same as for text(), for example), don't bother specifying it.
In some other cases, I find it clearer to specify xycoords in
terms of the more general
ax.transAxes
(i.e. "axes fraction")or
IdentityTransform()
(i.e. "figure pixels"), or evenax.get_yaxis_transform()
(i.e.("axes fraction", "data")
) --transforms are a general, widely used concept, whereas transform strings
only apply to annotate().
PR Summary
PR Checklist