Skip to content

Conversation

@Peiderk
Copy link
Collaborator

@Peiderk Peiderk commented Jan 9, 2026

This solution solves the collections attribute deprecation in matplotlib draw_colors_contours, but the plots weigh almost double as much storage and the shapes on the map have worse boundaries.

@Peiderk Peiderk marked this pull request as draft January 9, 2026 15:48
@Peiderk Peiderk changed the title Dirty solution to issue 70 Issue 70 Jan 9, 2026
@Peiderk Peiderk changed the title Issue 70 Issue #70 Jan 9, 2026
@Peiderk
Copy link
Collaborator Author

Peiderk commented Jan 12, 2026

This solution rasterizes collections from a less specific selection as what was possible using the attribute collections, which has been deprecated in matplotlib, and for what doesn't need to (and can't) get rasterized it simply fails to do so and filter out the warning. not the cleanest solution but has the same result as previously while solving the deprecation issue

@Peiderk Peiderk linked an issue Jan 12, 2026 that may be closed by this pull request
@Peiderk Peiderk marked this pull request as ready for review January 12, 2026 14:52
@Peiderk Peiderk requested a review from pirmink January 12, 2026 14:52
Copy link
Collaborator

@pirmink pirmink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solving the deprecation issue is important to be able to move to newer versions, so the workaround which includes filtering error messages is ok until a cleaner solution is found.

Copy link
Collaborator

@pirmink pirmink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment as suggested and change title to something indicating the problem.

for contour in contours.collections:
contour.set_rasterized(True)

new = ax.ax.collections[len(before):]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
new = ax.ax.collections[len(before):]
# Workaround for deprecated contours.collection:
# Loop over ax.collections, ignore warning that are produced for collections
# that cannot be rasterized.
new = ax.ax.collections[len(before):]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collections attribute deprecation in matplotlib draw_colors_contours

3 participants