FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Doc]: Example for "Scale invariant angle label" does not scale the arc correctly · Issue #22392 · matplotlib/matplotlib · GitHub

Repository navigation

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

Open

Description

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

Expected outcome

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

Activity

  1. 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[/+] on Feb 4, 2022
  2. jklymak commented on Feb 4, 2022

    Member

    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...

  3. QuLogic commented on Feb 5, 2022

    Member

    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.

  4. kkoutris commented on May 1, 2022

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

  5. andrew-fennell commented on May 10, 2022

    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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL