8000 FIX: Create a new ScalarMappable for axes_grid test · matplotlib/matplotlib@c86c7d1 · GitHub
[go: up one dir, main page]

Skip to content

Commit c86c7d1

Browse files
committed
FIX: Create a new ScalarMappable for axes_grid test
There is some shared state when adding colorbars to the axes_grid test here due to competing calls with colorbar.update_normal. To avoid that, we create a new ScalarMappable instance that creates a new norm that doesn't share state.
1 parent ebcbe75 commit c86c7d1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/mpl_toolkits/tests/test_axes_grid.py

-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,13 @@ def test_imagegrid_cbar_mode_edge():
4040
ax3.imshow(np.abs(arr), cmap='jet')
4141
ax4.imshow(np.arctan2(arr.imag, arr.real), cmap='hsv')
4242

43-
# In each row/column, the "first" colorbars must be overwritten by the
44-
# "second" ones. To achieve this, clear out the axes first.
4543
for ax in grid:
46-
ax.cax.cla()
4744
# We don't want to share the norms between the colorbar axes
4845
# so create a deepcopy for each image
49-
ax.images[0].norm = copy.deepcopy(ax.images[0].norm)
46+
sm = mpl.cm.ScalarMappable(norm=copy.deepcopy(ax.images[0].norm),
47+
cmap=ax.images[0].get_cmap())
5048
cb = ax.cax.colorbar(
51-
ax.images[0],
49+
sm,
5250
ticks=mpl.ticker.MaxNLocator(5)) # old default locator.
5351

5452

0 commit comments

Comments
 (0)
0