How to add lines to contour plot in python `matplotlib`?
<p>I have the following function to illustrate some contour lines :</p>

<pre><code>"""
Illustrate simple contour plotting, contours on an image with
a colorbar for the contours, and labelled contours.

See also contour_image.py.
"""
import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt

matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'

X = np.arange(-1.2, 1.2, 0.005)
Y = np.arange(-1.2, 1.2, 0.005)
X, Y = np.meshgrid(X, Y)
Z = (np.ones([np.shape(X)[0],np.shape(X)[1]])-X)**2+100*(Y-(X)**2)**2


# Create a simple contour plot with labels using default colors.  The
# inline argument to clabel will control whether the labels are draw
# over the line segments of the contour, removing the lines beneath
# the label
levels = np.arange(-100.0, 600, 1.0)
plt.figure()
CS = plt.contour(X, 
                 Y, 
                 Z,
                 levels=levels,
                )
plt.clabel(CS, 
           np.array(filter(lambda lev: lev &lt;5.0, levels)),
           inline=0.5, 
           fontsize=10,
           fmt='%1.1f'
          )

plt.hold(True)


plt.plot(np.arange(-1.0, 1.0, 0.005),
        np.arange(-1.0, 1.0, 0.005),
        np.ones(len(np.arange(-1.0, 1.0, 0.005)))*100, '-k')

plt.title('Contour Lines and Constraint of Rosenbrock Optimiztion Problem')
plt.show()
</code></pre>

<p><a href="https://i.stack.imgur.com/pomiv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pomiv.png" alt="enter image description here"></a></p>

<p>The contour plot looks great if you comment out the lines....:</p>

<pre><code># plt.hold(True)


# plt.plot(np.arange(-1.0, 1.0, 0.005),
#         np.arange(-1.0, 1.0, 0.005),
#         np.ones(len(np.arange(-1.0, 1.0, 0.005)))*100, '-k')
</code></pre>

<p><a href="https://i.stack.imgur.com/asziR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/asziR.png" alt="enter image description here"></a></p>

<p>...but I cannot get the lines to show up overlayed on the plot like I need them.  I just simply need them to be overlayed on top of the contour plot. What is the best way to do this?  </p>

<p>I know it is <a href="https://stackoverflow.com/questions/28458192/r-add-a-line-to-contour-plot">possible in R</a>, but how to do this in <code>Python</code> using <code>matplotlib</code>?</p>