Closed
Description
Bug summary
Calling the colorbar
method of one Figure
object does not attach the colour bar to that figure, but to the one where the object informing the colour scale resides.
Code for reproduction
from matplotlib.pyplot import subplots
import numpy as np
fig1, axes1 = subplots()
fig2, axes2 = subplots()
fig1.suptitle("Figure 1")
fig2.suptitle("Figure 2")
image1 = axes1.imshow(np.random.random((9,9)))
image2 = axes2.imshow(np.random.random((9,9)))
fig2.colorbar(image1)
Actual outcome
The colour bar gets attached to Image 1:
Expected outcome
The colour bar should get attached to Image 2. At the very least there should be an error.
Matplotlib Version
3.7.1
Installation
pip