Closed
Description
This only occurs with 2.2rc1 (and the current tip of that branch). The following code:
import matplotlib.pyplot as plt
import numpy as np
gx = np.linspace(-5, 5, 10)
img = np.hypot(gx, gx[:, None])
fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
mesh = ax.pcolormesh(gx, gx, img)
plt.colorbar(mesh)
plt.show()
produces:
Traceback (most recent call last):
File "test-error.py", line 10, in <module>
plt.colorbar(mesh)
File "/Users/rmay/repos/matplotlib/lib/matplotlib/pyplot.py", line 2225, in colorbar
ret = gcf().colorbar(mappable, cax = cax, ax=ax, **kw)
File "/Users/rmay/repos/matplotlib/lib/matplotlib/figure.py", line 2062, in colorbar
cax, kw = cbar.make_axes(ax, **kw)
File "/Users/rmay/repos/matplotlib/lib/matplotlib/colorbar.py", line 1135, in make_axes
gs = parents[0].get_subplotspec().get_gridspec()
AttributeError: 'Axes' object has no attribute 'get_subplotspec'
The line in question:
matplotlib/lib/matplotlib/colorbar.py
Lines 1134 to 1136 in 9b48fd8
Seems to have crept in with the constrained layout manager--I'm not sure what the proper fix is.