The Wayback Machine - https://web.archive.org/web/20231130033351/https://github.com/matplotlib/matplotlib/issues/20906
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.5.0b1: ax.contour generates different artists #20906

Closed
mwaskom opened this issue Aug 25, 2021 · 5 comments
Closed

3.5.0b1: ax.contour generates different artists #20906

mwaskom opened this issue Aug 25, 2021 · 5 comments
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@mwaskom
Copy link

mwaskom commented Aug 25, 2021

Bug summary

The artists added when using ax.contour have changed abruptly from 3.4 to the 3.5 beta. This causes issues for workflows that use the artist properties.

Code for reproduction

import numpy as np
import matplotlib.pyplot as plt

xx, yy = np.mgrid[-3:3:.01, 0:1:.05]
zz = np.sin(xx * yy)

ax = plt.figure().subplots()
ax.contour(xx, yy, zz)
print(ax.collections[0].__class__)

Actual outcome

The result on 3.5.0b1:

<class 'matplotlib.collections.PathCollection'>

Expected outcome

The result on 3.4.1:

<class 'matplotlib.collections.LineCollection'>
@tacaswell tacaswell added this to the v3.5.0 milestone Aug 25, 2021
@tacaswell
Copy link
Member

@mwaskom What are you doing with the return of get_segments? I am 👎🏻 on backing out these changes, but we need a better mitigation / migration story for the people we have broken.

attn @ianthomas23

@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Aug 25, 2021
@mwaskom
Copy link
Author

mwaskom commented Aug 25, 2021

In seaborn, just accessing them to test the 2D kdeplot results.

Like #20895, I don't think this affects any user-facing code, so it's not especially critical for me.

But since my test suite turned up an unexpected breakage, I thought it was good to report anyway.

@ianthomas23
Copy link
Member

@mwaskom The change in class returned by contour from LineCollection to PathCollection is intended. The PR (#19623) fixes a bug that has been around for many years in that closed line loops were rendered as open line strips so the ends were not joined correctly. To fix this it was necessary internally to use the CLOSEPOLY Path code. LineCollection doesn't support the use of codes whereas PathCollection does, hence the change.

There should certainly have been a note about the API change. If someone else wants to pick this up that would be great - I am on holiday at the moment and start a new job next week so mpl is not my highest priority in the short term.

@mwaskom
Copy link
Author

mwaskom commented Aug 26, 2021

I appreciate that it was intentional. FWIW, forward guidance on such changes a version or so in advance (either just in release notes, or ideally with a future warning) would reduce the change of abrupt breakage.

QuLogic added a commit to QuLogic/matplotlib that referenced this issue Sep 28, 2021
Also, update documentation for Attributes.

Followup to matplotlib#19623; fixes matplotlib#20906.
QuLogic added a commit to QuLogic/matplotlib that referenced this issue Sep 29, 2021
Also, update documentation for Attributes.

Followup to matplotlib#19623; fixes matplotlib#20906.
@timhoffm
Copy link
Member

Is @QuLogic ‘s documentation enough to close this issue?

tacaswell pushed a commit to tacaswell/matplotlib that referenced this issue Oct 12, 2021
Also, update documentation for Attributes.

Followup to matplotlib#19623; fixes matplotlib#20906.
tacaswell pushed a commit that referenced this issue Oct 20, 2021
Also, update documentation for Attributes.

Followup to #19623; fixes #20906.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

No branches or pull requests

4 participants