In [2]:
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'

%matplotlib inline
In [9]:
delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)

# difference of Gaussians
Z = 10.0 * (Z2 - Z1)
In [13]:
# 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
plt.figure()
CS = plt.contour(x, y, Z)
plt.clabel(CS, inline=1, fontsize=10)
plt.title('Simplest default with labels')
Out[13]:
<matplotlib.text.Text at 0x7fcfeedc1310>
In [14]:
Z.shape, x.shape, y.shape
Out[14]:
((160, 240), (240,), (160,))
In [15]:
Z
Out[15]:
array([[-0.0023928 , -0.00257835, -0.00277656, ..., -0.00298812,
        -0.00277655, -0.00257834],
       [-0.00251469, -0.0027097 , -0.00291801, ..., -0.00314034,
        -0.00291799, -0.00270968],
       [-0.00264115, -0.00284596, -0.00306474, ..., -0.00329825,
        -0.00306472, -0.00284594],
       ..., 
       [ 0.00817778,  0.00845885,  0.00874442, ...,  0.16478335,
         0.16144524,  0.15812319],
       [ 0.00732895,  0.00757579,  0.00782611, ...,  0.14989083,
         0.14686179,  0.14384672],
       [ 0.00654051,  0.00675572,  0.00697347, ...,  0.13599164,
         0.1332508 ,  0.13052201]])