I want to plot two heatmaps side by side, using figures and axes, but I can't seem to get the colorbar to show the counts for each color.
It works when I use the procedural style like this:
x1 = np.random.normal(size=1000)
y1 = np.random.normal(size=1000)
cmap = mpl.cm.plasma
plt.hist2d(x1, y1, cmap=cmap, bins=30)
plt.colorbar()
plt.show()
but not when I uses the OOP style:
x1 = np.random.normal(size=1000)
y1 = np.random.normal(size=1000)
fig, ax1 = plt.subplots(1, 1)
cmap = mpl.cm.plasma
ax1.hist2d(x1, y1, cmap=cmap, bins=30)
fig.colorbar(mpl.cm.ScalarMappable(cmap=cmap), ax=ax1)
plt.show()