In [1]:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline

In [2]:
x     = np.linspace(-1.0, 1.0, 100, endpoint=True)
y     = np.linspace(-1.0, 1.0, 100, endpoint=True)
X, Y  = np.meshgrid(x,y)

In [3]:
func  = lambda x, y: x**2 - y**2

In [4]:
Z     = func(X,Y)

Basic template


In [5]:
f,a  = plt.subplots()
cs   = a.contour(X,Y,Z)
a.clabel(cs)


Out[5]:
<a list of 14 text.Text objects>

Customization


In [6]:
levels = [-0.4, -0.1, 0.1, 0.4]
colors         = ('blue', 'lightblue', 'pink', 'red')
linestyles     = '--'

In [7]:
f,a  = plt.subplots()
cs   = a.contour(X,Y,Z, levels=levels, colors=colors, linestyles=linestyles)
a.clabel(cs)


Out[7]:
<a list of 8 text.Text objects>