Skip to content

Arc patch with starting and ending angle #8046

Closed

Description

@pdhall99

Bug report

Bug summary

  • Arc patch does not behave as expected when drawing elliptical arcs between two angles specified by theta1 and theta2.

Code for reproduction

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

# Ellipse parameters
R = 1.0
x, y = 0.0, 0.0
a, b = 2.0*R, R

# Figure setup
fig_width, fig_height = 3.30, 3.30
fig = plt.figure(figsize=(fig_width, fig_height), frameon=False)
ax = fig.add_axes([0.0, 0.0, 1.0, 1.0], aspect='equal')
ax.set_axis_off()
ax.set_xlim(-R*1.05, R*1.05)
ax.set_ylim(-R*1.05, R*1.05)
# Axes
ax.axhline(0.0)
ax.axvline(0.0)
# 45 degree line
ax.plot([0.0, 1.0], [0.0, 1.0], 'k--')
# Arcs
ax.add_patch(Arc((x, y), a, b, 
                 theta1=0.0, theta2=360.0, edgecolor='k'))
ax.add_patch(Arc((x, y), a, b,
                 theta1=0.0, theta2=45.0, edgecolor='r', lw=1.5))
fig.savefig('Arc_patch_bug.png')

Actual outcome

arc_patch_bug

Expected outcome

  • Red elliptical arc between the x-axis (0 degrees) and the dashed line (45 degrees), following the black ellipse.

Matplotlib version

  • Matplotlib 2.0.0, Python 2.7.13, OSX
  • Installed with MacPorts

Activity

  1. dstansby commented on Feb 8, 2017

    @dstansby
    Member

    I'm trying to run your example, but you haven't specified angle_deg anywhere in the code (so adding the patches fails).

  2. dstansby commented on Feb 8, 2017

    @dstansby
    Member

    I can reproduce this using a stripped down example:

    import matplotlib.pyplot as plt
    from matplotlib.patches import Arc
    
    # Ellipse parameters
    R = 1
    x, y = 0, 0
    a, b = 2 * R, R
    
    # Figure setup
    fig, ax = plt.subplots()
    ax.set_xlim(-R * 1.05, R * 1.05)
    ax.set_ylim(-R * 1.05, R * 1.05)
    # 45 degree line
    ax.plot([0, 1], [0, 1])
    # Arcs
    ax.add_patch(Arc((x, y), a, b,
                     theta1=0, theta2=360, edgecolor='k'))
    ax.add_patch(Arc((x, y), a, b,
                     theta1=0, theta2=45, edgecolor='r', lw=1.5))
    plt.show()
    

    I'm guessing this is because the aspect ratio of the ellipse isn't 1

  3. pdhall99 commented on Feb 8, 2017

    @pdhall99
    Author

    I'm trying to run your example, but you haven't specified angle_deg anywhere in the code (so adding the patches fails).

    Thanks for pointing out that error. I've corrected it in the original report.

  4. added this to the milestone on Feb 8, 2017
  5. self-assigned this
    on Feb 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions