-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Updated Angles on Bracket arrow styles example to make angles clear #23176 #24145
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 don't think the what's new should be updated mostly cause I don't think this will be very discoverable there and also cause I think we try to avoided updating the what's new docs. Can you please make this an example in annotations and then link the API docs for arrows to it? @timhoffm may have a better suggestion but I'm not sure what the policy is in terms of these kinds of figures in the reference docs. ETA: Thanks so much for making this figure and putting in the PR, I'm way psyched for it's existence even if I'm being a grump on placement. |
I wouldn't have a problem updating "what's new" in this case. This is "only" a visual improvement of an existing plot. However, I agree that it's not very discoverable in there.
Fundamentally, illustrating plots are fine the reference docs, see e.g. the notes section of https://matplotlib.org/devdocs/api/ticker_api.html#matplotlib.ticker.ScalarFormatter. However the example code is quite long and would clutter the docstring. So, placing it in the text/annotations section of the examples and linking in the plot via |
be2a1a3
to
9641fff
Compare
Hi @timhoffm and @story645 I've updated the PR with the proposed changes. I created a new example and linked it to matplotlib.patches.ArrowStyle in the example references. I also referenced the example in the ArrowStyle docstring. When I build the documentation it shows up as an example but it does not pull through to https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.ArrowStyle.html#matplotlib.patches.ArrowStyle - I assume I'm missing something here so please assist with that. |
You've squashed some unrelated commits in here. An easy way to fix is to copy the two files you wanted to change somewhere else, On your branch do |
9641fff
to
f95cdd3
Compare
Hi @jklymak, not sure how that commit got entangled with mine. I tried this without avail, received the following:
I went ahead and synced my branch with matplotlib:main from GitHub ("sync fork") and then pulled again but now it looks like some of the changes are already merged, so I'm a bit confused. Not sure what to do now. Please assist and sorry for the mess. |
You need to add a "remote" called |
1b726d0
to
4a3537b
Compare
Hi @jklymak, thanks I managed to set the upstream and then I ran:
Then made the changes again on my branch and ran:
I think it should be good now. Please confirm. |
Looks better. Congrats! |
from matplotlib.patches import Arc, FancyArrowPatch | ||
from matplotlib.transforms import Bbox, IdentityTransform, TransformedBbox | ||
|
||
|
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.
does importing AngleAnnotation from angle_annotation.py work?
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.
Importing AngleAnnotation works but the plots from that example is also automatically generated in the docs then. Not sure if there is a way to exclude them?
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.
hmm, wonder if the trick there is to factor just the AngleAnnotation out into it's own .py file that gets excluded from the sphinx gallery listings and then use a literal block to show it in the scale invariant tutorial.
lib/matplotlib/patches.py
Outdated
Examples | ||
-------- | ||
.. plot:: gallery/text_labels_and_annotations/angles_on_bracket_arrows.py |
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.
do we usually call this section examples or is notes to be consistent with the other example?
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 noticed "Examples" in some docstrings, and "Notes" in others. Seemed like "Examples" was more prevalent. This change did not add the mini gallery to the docs page. Is this the way to do that?
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.
Sorry I spaced - I think notes or examples is contextual and here this plot is a note about how angles work more than an example of how to use brackets
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.
Also according to our docs, the mini gallery should have been registered as part of the references https://matplotlib.org/devdocs/devel/documenting_mpl.html#references-for-sphinx-gallery
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.
Sorry I spaced - I think notes or examples is contextual and here this plot is a note about how angles work more than an example of how to use brackets
Got it, thanks. Will update tot a Note.
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.
Also according to our docs, the mini gallery should have been registered as part of the references https://matplotlib.org/devdocs/devel/documenting_mpl.html#references-for-sphinx-gallery
Is anything else missing @story645? Any ideas why it is not registered?
f7d81ec
to
84a3c92
Compare
So I apologize profusely for doing this now, but I have an idea that might simplify things? Maybe instead of making this a new example (w/ all the annoyances of copying the ArcAnnotation class), this gets folded into the ArcAnnotation example as a second example? And then we title that example something like annotating angles - direction and scale invariance? B/C the direction stuff is what's really useful here as an example, and that the figure makes a good bracket reference is kind of independent...(and yes this then is maybe a tutorial, but that's out of scope here) You can still keep the link to the figure in the reference using the sphinx gallery reference tags https://sphinx-gallery.github.io/stable/advanced.html#cross-referencing |
The failing test doesn't seem related to this PR:
|
Good suggestion. Alternatively, we could also leave out AngleAnnotation completely (which basically just provides the angle size in this case) and only add the directional arrow. That's what we are really after from the start right, more clarity on the angle direction? It would then look like this: |
I'd still like labeling of the angle between bracket and perpendicular, but that can probably be achieved w/ ax.text placed relative to the perpendicular. Also I really like your suggestion! |
Either one is cool, please let me know what the preferred way is 👌🏻 |
I agree w/ you on leaving out ArcAnnotation, (I really like that it's a simpler way to label angles) but if you're gonna go that route please label the angle with ax.text instead. |
Ah, missed a sneaky space there. Should be fixed now. Sorry about that. |
No problem/apology needed/wish it was easier to find the errors in the logs :/ |
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.
Um that first commit needs to be removed before I merge this. Can you try rebasing against main and dropping that first commit? If you need help let somebody (me) know! |
examples/text_labels_and_annotations/angles_on_bracket_arrows.py
Outdated
Show resolved
Hide resolved
a500e3b
to
298da48
Compare
…example to make angles clear matplotlib#23176
Thanks @jacoverster! Congratulations on your first PR to Matplotlib 🎉 We hope to hear from you again. |
|
…atplotlib#23176 (matplotlib#24145) * removed AngleAnnotation from angle_on_bracket_arrow example * Fixes indentation mistake. * rebase to main, remove conflicting commit
PR Summary
PR relates to this issue. Added
AngleAnnotation
patches to mark the angles and includedFancyArrowPatch
arrows to show the directions of AngleA and AngleB.PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).