Skip to content

[Bug]: plt.autoscale() fails for partial Arc #23329

Closed

Description

@StFroese

Bug summary

Using plt.autoscale() for an Arc with theta1 & theta2 for a not full ellipse results in a wrong scaling.

For example:

Arc((0,0),1,1,theta1=0,theta2=90)

Code for reproduction

import matplotlib.pyplot as plt
from matplotlib.patches import Arc

fig, ax = plt.subplots()
ax.add_patch(Arc((0,0),1,1,theta1=0,theta2=90))

plt.autoscale()
plt.show()

Actual outcome

Figure

Expected outcome

I think it would be better to have a zoomed in version of the partial arc. Like this:

FigureC

Additional information

No response

Operating system

No response

Matplotlib Version

3.5.2

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

No response

Activity

  1. oscargus commented on Jun 24, 2022

    @oscargus
    Member

    The reason is that the path that is stored is for a complete Ellipse and that the angles are not taken into account until draw time. As the bounding box is determined from the saved path this is what happens...

    This can be seen be e.g.

    from matplotlib.patches import Arc
    a = Arc((0,0),1,1,theta1=0,theta2=90)
    print(a.get_path())
    print(a.get_extents())
    

    A solution to this is probably to define a better get_path-method for Arc.

  2. oscargus commented on Jun 24, 2022

    @oscargus
    Member

    This is vaguely related (solving this may solve that): #19550

    Also this can be worth considering: #11266

  3. StFroese commented on Jun 24, 2022

    @StFroese
    Author

    @oscargus Thanks a lot!

  4. added this to the v3.6.0 milestone on Aug 20, 2022
  5. changed the title [-][Bug]: `plt.autoscale()` failes for partial `Arc`[/-] [+][Bug]: `plt.autoscale()` fails for partial `Arc`[/+] on Aug 22, 2022
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions