Think this could example could be better but you get the gist
import numpy as np
from scipy.optimize import _minimize
from scipy import special
import matplotlib.pyplot as plt
from matplotlib import cm
from numpy.random import randn
x, y = np.mgrid[-2:2:100j, -2:2:100j]
plt.pcolor(x, y, optimize.rosen([x, y]))
plt.plot(1, 1, 'xw')
# Make plot with vertical (default) colorbar
data = np.clip(randn(100, 100), -1, 1)
cax = plt.imshow(data, cmap=cm.coolwarm)
# Add colorbar, make sure to specify tick locations to match desired ticklabels
cbar = plt.colorbar(cax, ticks=[-2, 0, 2]) # vertically oriented colorbar
plt.axis([-2, 2, -2, 2])
plt.title('Rosenbrock function') #add title if desired
plt.xlabel('x')
plt.ylabel('y')
plt.show() #generate