Skip to content

Commit f6a54ab

Browse files
committed
(1) turn off the grid after creating colorbar axes (2) added a test
1 parent 4af13d6 commit f6a54ab

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/matplotlib/tests/test_colorbar.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
import pytest
3-
import warnings
43

54
from matplotlib import cm
65
import matplotlib.colors as mcolors
@@ -941,15 +940,13 @@ def test_boundaries():
941940
cb = fig.colorbar(pc, ax=ax, boundaries=np.linspace(-3, 3, 7))
942941

943942

944-
def test_colorbar_no_warning():
943+
def test_colorbar_no_warning_rcparams_grid_true():
945944
# github issue #21723 - If mpl style has 'axes.grid' = True,
946945
# fig.colorbar raises a warning about Auto-removal of grids
947946
# by pcolor() and pcolormesh(). This is fixed by PR #22216.
948-
with warnings.catch_warnings(record=True) as w:
949-
plt.rcParams['axes.grid'] = True
950-
fig, ax = plt.subplots()
951-
ax.grid(False)
952-
im = ax.pcolormesh([0, 1], [0, 1], [[1]])
953-
fig.colorbar(im)
954-
# make sure that no warning is raised
955-
assert len(w) == 0
947+
plt.rcParams['axes.grid'] = True
948+
fig, ax = plt.subplots()
949+
ax.grid(False)
950+
im = ax.pcolormesh([0, 1], [0, 1], [[1]])
951+
# make sure that no warning is raised by fig.colorbar
952+
fig.colorbar(im)

0 commit comments

Comments
 (0)