Skip to content

[Doc]: Bracket ArrowStyle Angle Unclear #23176

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

Closed
story645 opened this issue Jun 1, 2022 · 18 comments · Fixed by #24145
Closed

[Doc]: Bracket ArrowStyle Angle Unclear #23176

story645 opened this issue Jun 1, 2022 · 18 comments · Fixed by #24145
Labels
Documentation Good first issue Open a pull request against these issues if there are no active ones!

Comments

@story645
Copy link
Member

story645 commented Jun 1, 2022

Documentation Link

https://matplotlib.org/devdocs/users/prev_whats_new/whats_new_3.4.0.html?highlight=bracket#angles-on-bracket-arrow-styles

Problem

I can't tell from this figure what Angle = 60 is relative to, since the top angle is >60 and the lower angle is <60 in the first example, and '0 degrees means perpendicular to the line' is buried in the api docs (I missed what that means like 6 times)

image

Suggested improvement

An example, that's cross referenced against the API docs, where the angle is marked up, similar to the scale invariant docs
image

I think it'd be nice to include the formulas for setting the bracket horizontal or vertical relative to the axes, but that's totally extra. I think it's a good first issue since it's completely standalone, a relatively small addition, and this information is missing.

@story645 story645 added Documentation Good first issue Open a pull request against these issues if there are no active ones! labels Jun 1, 2022
@llricci
Copy link
Contributor

llricci commented Jun 13, 2022

Hello, I would like to work with that issue. However, I think I did not completely understand your idea, it is to draw the angles in the image to make it more clear, like in your sugestion?

@story645
Copy link
Member Author

story645 commented Jun 13, 2022

Exactly, a

  1. new gallery example (this may end up appended to an existing example, but easier if you start it new)
  2. that looks like the bracket example from what's new
  3. where the angle argument is annotated like in the scale invariant angle 171474679-ee821900-35a2-4355-8759-bff6aad1ab63__01.png

@llricci
Copy link
Contributor

llricci commented Jun 14, 2022

@story645 Something like this?
image

@story645
Copy link
Member Author

Yup, except the angle is always between the brace and the perpendicular

@llricci
Copy link
Contributor

llricci commented Jun 14, 2022

I see, but I'm unsure how I would do that with matplotlib

@story645
Copy link
Member Author

I think by importing the ArcAnnotation class from the scale invariant example (you can cross link in the text) and using that to label the angles. I think the perpendicular can be drawn using either vlines or plot.

@llricci
Copy link
Contributor

llricci commented Jun 14, 2022

Ok, thanks. I'll see this tomorrow

@llricci
Copy link
Contributor

llricci commented Jun 15, 2022

I successfully created the lines using vlines() but I can't do the same with Arc()

Figure_1

@jacoverster
Copy link
Contributor

jacoverster commented Oct 7, 2022

Hi @story645, can I contribute to this issue? Is this what you are looking for:

image

@story645
Copy link
Member Author

story645 commented Oct 7, 2022

That looks great! Go for it!!!

@timhoffm
Copy link
Member

timhoffm commented Oct 7, 2022

Bonus: Maybe add an arrow head to the grey arc to indicate the angle direction (from the blue line to the bracket)?

@jacoverster
Copy link
Contributor

Sure thing @timhoffm, I'll look into that.

@jacoverster
Copy link
Contributor

jacoverster commented Oct 11, 2022

Hi @timhoffm, I looked at a few ways of adding the arrows.

One way is to simply add a FancyArrowPatch to the plot (as shown below), but this won't be scale invariant.

image

Secondly, I added an arrow annotation to AngleAnnotation (similar to the text annotation):

self.arrow = ax.annotate("", xy=(0.5, 0.5), xytext=(0, 0), arrowprops=arrowprops, **self.kw)

I then tried to update it's position at plot time. I can easily set self.arrow.yx (similar to self.text.xy) but can't access the xytext variable (arrow._arrow_relpos I believe) to tell the updated arrow where to point from.

Is it possible to set this during plot time, and if not do you have any other suggestions? Am I on the right track or is the FancyArrowPatch solution fine?

@timhoffm
Copy link
Member

The FancyArrowPatch is fine here. This is mainly used as a static illustration in the docs. Scale invariance is not important.

@jacoverster
Copy link
Contributor

jacoverster commented Oct 12, 2022

Hi @timhoffm or @story645 is there a way to import the AngleAnnotation code from examples/text_labels_and_annotations/angle_annotation.py into whats-new-3-4-0.rst? I've read through the contribution guide and can't find an example of this. Thanks, ready to submit the PR then.

@story645
Copy link
Member Author

story645 commented Oct 12, 2022

I was thinking this becomes a gallery example w/ the other annotation examples and is then linked to at the bottom of https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.ArrowStyle.html#matplotlib.patches.ArrowStyle in the way that examples are linked in https://matplotlib.org/devdocs/api/_as_gen/matplotlib.patches.Arrow.html

Then you also should be able to import the code since it'll be in the same folder.

@jacoverster
Copy link
Contributor

Ok thanks for the guidance @story645, first contributor here so a lot to learn 👌🏻😁 Appreciate it.

Should I delete the PR?

@story645
Copy link
Member Author

Absolutely not! Please just update the PR by restoring the what's new, creating a new example, and updating the arrow style docstrings to point to the example https://sphinx-gallery.github.io/stable/configuration.html#add-mini-galleries-for-api-documentation

QuLogic pushed a commit that referenced this issue Oct 26, 2022
…23176 (#24145)

* removed AngleAnnotation from angle_on_bracket_arrow example

* Fixes indentation mistake.

* rebase to main, remove conflicting commit
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this issue Oct 26, 2022
story645 added a commit that referenced this issue Oct 26, 2022
…145-on-v3.6.x

Backport PR #24145 on branch v3.6.x (Updated Angles on Bracket arrow styles example to make angles clear #23176)
melissawm pushed a commit to melissawm/matplotlib that referenced this issue Dec 19, 2022
…atplotlib#23176 (matplotlib#24145)

* removed AngleAnnotation from angle_on_bracket_arrow example

* Fixes indentation mistake.

* rebase to main, remove conflicting commit
@ksunden ksunden mentioned this issue Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Good first issue Open a pull request against these issues if there are no active ones!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants