Skip to content

Commit 7bb4313

Browse files
committed
Added a test
1 parent 6914544 commit 7bb4313

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/matplotlib/tests/test_colorbar.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import numpy as np
22
import pytest
3+
import warnings
34

45
from matplotlib import cm
56
import matplotlib.colors as mcolors
@@ -938,3 +939,17 @@ def test_boundaries():
938939
fig, ax = plt.subplots(figsize=(2, 2))
939940
pc = ax.pcolormesh(np.random.randn(10, 10), cmap='RdBu_r')
940941
cb = fig.colorbar(pc, ax=ax, boundaries=np.linspace(-3, 3, 7))
942+
943+
944+
def test_colorbar_no_warning():
945+
# github issue #21723 - If mpl style has 'axes.grid' = True,
946+
# fig.colorbar raises a warning about Auto-removal of grids
947+
# 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

0 commit comments

Comments
 (0)