Skip to content

[Doc]: Example for "Scale invariant angle label" does not scale the arc correctly #22392

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

Open
wayofsamu opened this issue Feb 4, 2022 · 4 comments
Labels
Documentation: examples files in galleries/examples

Comments

@wayofsamu
Copy link

wayofsamu commented Feb 4, 2022

Bug summary

When setting a dpi value and using unit = 'points' in the AngleAnnotation example class, it does not scale the Arc width and height correctly. I will use the example from the link above to show the problem:

Code for reproduction

fig, ax = plt.subplots(dpi=300)
fig.canvas.draw()  # Need to draw the figure to define renderer
ax.set_title("AngleLabel example")

# Plot two crossing lines and label each angle between them with the above
# ``AngleAnnotation`` tool.
center = (4.5, 650)
p1 = [(2.5, 710), (6.0, 605)]
p2 = [(3.0, 275), (5.5, 900)]
line1, = ax.plot(*zip(*p1))
line2, = ax.plot(*zip(*p2))
point, = ax.plot(*center, marker="o")

am1 = AngleAnnotation(center, p1[1], p2[1], ax=ax, size=75, text=r"$\alpha$")
am2 = AngleAnnotation(center, p2[1], p1[0], ax=ax, size=35, text=r"$\beta$")
am3 = AngleAnnotation(center, p1[0], p2[0], ax=ax, size=75, text=r"$\gamma$")
am4 = AngleAnnotation(center, p2[0], p1[1], ax=ax, size=35, text=r"$\theta$")


# Showcase some styling options for the angle arc, as well as the text.
p = [(6.0, 400), (5.3, 410), (5.6, 300)]
ax.plot(*zip(*p))
am5 = AngleAnnotation(p[1], p[0], p[2], ax=ax, size=40, text=r"$\Phi$",
                      linestyle="--", color="gray", textposition="outside",
                      text_kw=dict(fontsize=16, color="gray"))
plt.show()

Actual outcome

ActualOutcome

Expected outcome

ExpectedOutcome

The expected outcome can be produced when changing size to get_size() in the Arc initialisation.

super().__init__(self._xydata, self.get_size(), self.get_size(), angle=0.0,
                 theta1=self.theta1, theta2=self.theta2, **kwargs)

Additional information

No response

Operating system

No response

Matplotlib Version

3.5.1

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

@jklymak jklymak changed the title [Bug]: Example for "Scale invariant angle label" does not scale the arc correctly [Doc]: Example for "Scale invariant angle label" does not scale the arc correctly Feb 4, 2022
@jklymak jklymak added the Documentation: website layout/behavior/styling changes label Feb 4, 2022
@jklymak
Copy link
Member

jklymak commented Feb 4, 2022

I agree that they have not quite threaded the dpi to physical units dance properly, OTOH, I'm not convinced the annotations are meant to go not he inside of the Arcs either, and in my machine they do not (hiDPI). Someone will have to go in and fix the transforms here...

@QuLogic
Copy link
Member

QuLogic commented Feb 5, 2022

OTOH, I'm not convinced the annotations are meant to go not he inside of the Arcs either, and in my machine they do not (hiDPI).

That depends on the textposition=['inside'|'outside'] parameter; it defaults to inside, I believe.

@kkoutris
Copy link

kkoutris commented May 1, 2022

I would like to work on this issue. Can someone guide me (where to look at) except angle_annotation.py ??

@andrew-fennell
Copy link
Contributor

I want to make sure I am clear on the actual issue here, as I'm reviewing #23027. The angle markings need to be scaled to take DPI into account so that the labels remain in the correct positions, correct?

Here is an image that demonstrates the issue on different DPIs:
image

The labels should always be inside the angle markings, but with different DPI settings, they are not.

@story645 story645 added Documentation: examples files in galleries/examples and removed Documentation: website layout/behavior/styling changes labels Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: examples files in galleries/examples
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants