Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Open
Labels
Milestone
Description
Bug summary
When running a poly collection, depending on the order of points (which shouldn't matter for < 4 points) the line anti-aliasing flips, which creates a different image. (So, creating pytests based on images where the point ordering is non-deterministic doesn't work)
Code for reproduction
See this repo, where I have laid out a testing env that reproduces the effect
https://github.com/lganic/matplotlib-collection-alias-testing.git
However this is the pertinent bit:
@pytest.mark.mpl_image_comparedeftest_collection():# Define one trianglestuff= [[0,0], [1,0], [1,1]]random.shuffle(stuff)# stuff = [[0, 0], [1, 0], [1, 1]] # Running with this commented out, will usually result in a different image.polys= [np.array(stuff)]print(polys)fig,ax=plt.subplots()ax.set_aspect('equal')# Add shaded trianglecoll=PolyCollection(polys,facecolors="lightblue",edgecolors="k",linewidths=1)ax.add_collection(coll)# Plot verticespts=np.vstack(polys)# stack back into N×2 array for scatterax.scatter(pts[:,0],pts[:,1],c='red',zorder=5)returnfig
Actual outcome
Zoomed in diff:

Diff highlighted in red:

Expected outcome
Both produced lines should have matching anti-aliasing.
Additional information
No response
Operating system
Windows 11
Matplotlib Version
3.10.6
Matplotlib Backend
qtagg
Python version
3.13.1
Jupyter version
N/A
Installation
pip