Skip to content

Commit ad61bf9

Browse files
committed
TST: test remove colorbar with CL
1 parent f399567 commit ad61bf9

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/matplotlib/tests/test_colorbar.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def test_colorbar_single_scatter():
221221
ids=['no gridspec', 'with gridspec'])
222222
def test_remove_from_figure(use_gridspec):
223223
"""
224-
Test `remove_from_figure` with the specified ``use_gridspec`` setting
224+
Test `remove` with the specified ``use_gridspec`` setting
225225
"""
226226
fig, ax = plt.subplots()
227227
sc = ax.scatter([1, 2], [3, 4], cmap="spring")
@@ -235,6 +235,23 @@ def test_remove_from_figure(use_gridspec):
235235
assert (pre_position.get_points() == post_position.get_points()).all()
236236

237237

238+
def test_remove_from_figure_cl():
239+
"""
240+
Test `remove` with constrained_layout
241+
"""
242+
fig, ax = plt.subplots(constrained_layout=True)
243+
sc = ax.scatter([1, 2], [3, 4], cmap="spring")
244+
sc.set_array(np.array([5, 6]))
245+
fig.draw_without_rendering()
246+
pre_position = ax.get_position()
247+
cb = fig.colorbar(sc)
248+
cb.remove()
249+
fig.draw_without_rendering()
250+
post_position = ax.get_position()
251+
np.testing.assert_allclose(pre_position.get_points(),
252+
post_position.get_points())
253+
254+
238255
def test_colorbarbase():
239256
# smoke test from #3805
240257
ax = plt.gca()

0 commit comments

Comments
 (0)