Skip to content

Explicitly remove grids for pcolormesh - #7219

Merged
dcherian merged 1 commit into
pydata:mainfrom
Illviljan:autogridding
Oct 28, 2022
Merged

dcherian merged 1 commit into
pydata:mainfrom
Illviljan:autogridding

Conversation

@Illviljan

@Illviljan Illviljan commented Oct 25, 2022 •

Copy link
Copy Markdown
Contributor

Removes a warning in the plotting tests, related to https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.5.0.html#auto-removal-of-grids-by-pcolor-and-pcolormesh.

I just added ax.grid(False) but maybe we just want whatever is the default of matplotlib?

import xarray as xr

airtemps = xr.tutorial.open_dataset("air_temperature")
air = airtemps.air - 273.15
air.attrs = airtemps.air.attrs
air.attrs["units"] = "deg C"

air2d = air.isel(time=500)
fig, axs = plt.subplots(2,1)
air2d.plot(ax=axs[0])  # No grid.
air2d.plot(ax=axs[1])  # With grid.
axs[1].grid(True)

image

@Illviljan Illviljan changed the title Explicitly remove grids for pcolormesh Explicitly remove grids for pcolormesh? Oct 25, 2022
@Illviljan
Illviljan marked this pull request as ready for review October 25, 2022 18:23

@headtr1ck headtr1ck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No preference on this.
I guess we can keep the current behavior and silence this warning :)

Loogs good.

@headtr1ck headtr1ck added the plan to merge Final call for comments label Oct 26, 2022
@Illviljan Illviljan changed the title Explicitly remove grids for pcolormesh? Explicitly remove grids for pcolormesh Oct 26, 2022
@dcherian
dcherian merged commit 7ff2b04 into pydata:main Oct 28, 2022
Sealdot added a commit to Sealdot/xarray that referenced this pull request Nov 20, 2026
pcolormesh unconditionally called ax.grid(False) before drawing, which overrode the axes.grid rcParam and grids enabled directly on the axes. The call was added in pydata#7219 to opt out of the matplotlib 3.5 deprecation warning about pcolor/pcolormesh automatically removing grids; matplotlib no longer removes the grid, so the explicit call now only hides a grid the user asked for.

Fixes pydata#11919

AI assistance: Cognition Devin CLI agent (SWE-2 High).

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Sealdot Sealdot mentioned this pull request Nov 20, 2026
6 of 7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan to merge Final call for comments topic-plotting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants