10000 [Bug]: Curves goes to infinity with limited points · Issue #26823 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: Curves goes to infinity with limited points #26823
Open
@carlos-adir

Description

@carlos-adir

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

Image without zoom
image

Image with zoom
image

Expected outcome

It's suposed to get the following image, or a section of this image without exploding

Perfect image
image

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]

New zoomed image
image

Operating system

Windows

Matplotlib Version

3.8.0

Matplotlib Backend

TkAgg

Python version

3.10.11

Jupyter version

No response

Installation

pip

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

      0