Closed
Description
Bug summary
When using plt.colorbar
along with plt.matshow
, the colorbar is taller than the plot. If I use plt.matshow(A, fig=0)
, then it is the same height as the plot.
Code for reproduction
# Basically https://matplotlib.org/stable/gallery/images_contours_and_fields/matshow.html#sphx-glr-gallery-images-contours-and-fields-matshow-py with a colorbar added
import matplotlib.pyplot as plt
import numpy as np
# a 2D array with linearly increasing values on the diagonal
a = np.diag(range(15))
plt.matshow(a) # this triggers the bug
# plt.matshow(a, fignum=None) # this too
# plt.matshow(a, fignum=1) # this too
# plt.matshow(a, fignum=False) # this triggers the expected outcome
# plt.matshow(a, fignum=0) # this too
plt.colorbar()
plt.show()
Actual outcome
Expected outcome
Additional information
No response
Operating system
Ubuntu 20.04
Matplotlib Version
3.5.2
Matplotlib Backend
QtAgg
Python version
Python 3.10.4
Jupyter version
none involved
Installation
conda
Metadata
Metadata
Assignees
Labels
No labels