multiple contourf plots with colorbar2

plot contourf cbar2
import numpy as np
import matplotlib.pyplot as plt

kw = {"height_ratios": [1,1],"width_ratios":[98,2]}
fig, ax = plt.subplots(2,2,  gridspec_kw=kw,figsize=(4,8))

x = np.linspace(-5,5,1000)
y = np.linspace(-5,5,1000)
X,Y = np.meshgrid(x,y)

H = lambda q,p: p**2/2 + np.cos(q)

ax[0,0].plot(x, np.sin(x))
ax[0,1].axis('off')
cf=ax[1,0].contourf(X,Y, H(X,Y), 10, cmap=plt.cm.hot_r)
fig.colorbar(cf, cax=ax[1,1])
plt.show()

Total running time of the script: ( 0 minutes 0.145 seconds)

Gallery generated by Sphinx-Gallery