Skip to content

3.5.0b1: ax.contour generates different artists #20906

Closed

Description

@mwaskom

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'>

Activity

  1. added this to the v3.5.0 milestone on Aug 25, 2021
  2. tacaswell commented on Aug 25, 2021

    @tacaswell
    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

  3. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Aug 25, 2021
  4. mwaskom commented on Aug 25, 2021

    @mwaskom
    Author

    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.

  5. ianthomas23 commented on Aug 26, 2021

    @ianthomas23
    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.

  6. mwaskom commented on Aug 26, 2021

    @mwaskom
    Author

    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.

  7. added 3 commits that reference this issue on Sep 28, 2021
    348478d
    36aa609
    1ed3542
  8. timhoffm commented on Sep 30, 2021

    @timhoffm
    Member

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

  9. added a commit that references this issue on Oct 12, 2021
    c13cc76
  10. added a commit that references this issue on Oct 20, 2021
    a9a7e5c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions