Open
Description
Bug summary
I'm trying to plot a closed curve made of linear and quadratic bezier using Path
and PathPatch
. But somehow it goes to infinity as shown in the images
Can anyone verify if this error is reproductible?
Code for reproduction
from matplotlib import pyplot as plt
from matplotlib.path import Path
from matplotlib.patches import PathPatch
points = [[0,2],[-4,2],[-4,-2],[0,-2],[2,-2],[2,0],[2,2],[0,2]]
codes = [1,2,2,2,3,3,3,79]
fig, ax = plt.subplots()
ax.grid()
path = Path(points, codes)
patch = PathPatch(path, color="lime", alpha=0.25)
ax.add_patch(patch)
path = Path(points, codes)
patch = PathPatch(path, edgecolor="red", facecolor="none", lw=2)
ax.add_patch(patch)
plt.xlim(-8, 8)
plt.ylim(-8, 8)
plt.show()
Actual outcome
Expected outcome
It's suposed to get the following image, or a section of this image without exploding
Additional information
By inserting the point (0, 2)
and the code 3
at the end, it solves globally the issue, but the red curve still explodes to infinity when a specific zoom in applied, as shown in the image.
points = [[0,2],[-4,2],[-4,-2],[0,-2],[2,-2],[2,0],[2,2],[0,2],[0,2]]
codes = [1,2,2,2,3,3,3,3,79]
Operating system
Windows
Matplotlib Version
3.8.0
Matplotlib Backend
TkAgg
Python version
3.10.11
Jupyter version
No response
Installation
pip