Skip to content

FancyArrowPatch path is changed when added to an axis #8694

Closed
@dstansby

Description

@dstansby

Bug report

Adding a FancyArrowPatch to an axis changes the result returned by get_path(). I would expect adding an artist to an axis to have no effect on its path in data co-ordinates.

Code for reproduction

import matplotlib.pyplot as plt
import matplotlib.patches as mpatch

# Create arrow patch
arrow = mpatch.FancyArrowPatch((0, 0), (0, 1))

# Print original path
print(arrow.get_path())
# Add to an axis
fig, ax = plt.subplots()
ax.add_artist(arrow)
# Print new path
print(arrow.get_path())

Actual outcome

Path(array([[-0.1       ,  0.        ],
       [-0.1       ,  0.25195312],
       [-0.1       ,  0.50390625],
       [-0.25      ,  0.50390625],
       [-0.125     ,  0.75195312],
       [ 0.        ,  1.        ],
       [ 0.125     ,  0.75195312],
       [ 0.25      ,  0.50390625],
       [ 0.1       ,  0.50390625],
       [ 0.1       ,  0.25195312],
       [ 0.1       ,  0.        ],
       [-0.1       ,  0.        ],
       [-0.1       ,  0.        ]]), array([ 1,  3,  3,  2,  3,  3,  3,  3,  2,  3,  3,  2, 79], dtype=uint8))


Path(array([[ -2.01612903e-04,   5.40924072e-03],
       [ -2.01612903e-04,   4.99324011e-01],
       [ -2.01612903e-04,   9.93238781e-01],
       [ -5.04032258e-04,   9.93238781e-01],
       [ -2.52016129e-04,   9.93914224e-01],
       [  0.00000000e+00,   9.94589667e-01],
       [  2.52016129e-04,   9.93914224e-01],
       [  5.04032258e-04,   9.93238781e-01],
       [  2.01612903e-04,   9.93238781e-01],
       [  2.01612903e-04,   4.99324011e-01],
       [  2.01612903e-04,   5.40924072e-03],
       [ -2.01612903e-04,   5.40924072e-03],
       [ -2.01612903e-04,   5.40924072e-03]]), array([ 1,  3,  3,  2,  3,  3,  3,  3,  2,  3,  3,  2, 79], dtype=uint8))

Expected outcome
Clearly the two paths are different - I expected them to be the same (and I would expect the first one to be the correct one based on the FancyArrowPatch docstring).

Matplotlib version

  • Operating System: OSX
  • Matplotlib Version: master branch
  • Python Version: 3.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions