I am trying to add colorbar for each subplot. The 3D data is like (x,y,z). My codes are like:
fig,ax = plt.subplots(2,2,figsize=(15,15))
ax[0,0].scatter(x,y,s=z,c=z,cmap='jet')
ax[0,0].set_xlabel('XXX')
ax[0,0].set_ylabel('YYY')
So I am able to add x,y labels, add title for each subplot, but I just can't add the colorbar.
My codes for colorbar in a single plot are like:
plt.colorbar(extend='both')
or
colorbar = plt.colorbar(label='test',orientation='horizontal',shrink=0.8,pad=0.05,extend='both')
I saw the previous Q&A here matplotlib colorbar in each subplot, but sorry I don't understand how to apply to my case. Is there a way to add the colorbar, just like how I added the xlabel and title, please? Many thanks.