Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6914544

Browse files
committed
Use rcParams context manager to turn off the grid when creating cax
1 parent e52a106 commit 6914544

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/matplotlib/colorbar.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,10 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
14491449
if panchor is not False:
14501450
ax.set_anchor(panchor)
14511451

1452-
cax = fig.add_axes(pbcb, label="<colorbar>")
1452+
# pcolormesh will eventually be called on the cax so turn off the grid
1453+
# when creating the cax
1454+
with mpl.rc_context({'axes.grid': False}):
1455+
cax = fig.add_axes(pbcb, label="<colorbar>")
14531456
for a in parents:
14541457
# tell the parent it has a colorbar
14551458
a._colorbars += [cax]
@@ -1566,7 +1569,10 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
15661569
parent.set_anchor(panchor)
15671570

15681571
fig = parent.get_figure()
1569-
cax = fig.add_subplot(ss_cb, label="<colorbar>")
1572+
# pcolormesh will eventually be called on the cax so turn off the grid
1573+
# when creating the cax
1574+
with mpl.rc_context({'axes.grid': False}):
1575+
cax = fig.add_subplot(ss_cb, label="<colorbar>")
15701576
cax.set_anchor(anchor)
15711577
cax.set_box_aspect(aspect)
15721578
cax.set_aspect('auto')

lib/matplotlib/figure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,6 @@ def colorbar(
11431143
cax, kwargs = cbar.make_axes_gridspec(ax, **kwargs)
11441144
else:
11451145
cax, kwargs = cbar.make_axes(ax, **kwargs)
1146-
cax.grid(visible=False, which='both', axis='both')
11471146
else:
11481147
userax = True
11491148

0 commit comments

Comments
 (0)