First page Back Continue Last page Overview Graphics

Example

import numpy as np

import matplotlib.pyplot as plt

xlist = np.linspace(-3.0, 3.0, 100)

ylist = np.linspace(-3.0, 3.0, 100)

X, Y = np.meshgrid(xlist, ylist)

Z = np.sqrt(X ** 2 + Y ** 2 )

plt.figure()

levels = [0.0, 0.2, 0.5, 0.9, 1.5, 2.5, 3.5]

contour = plt.contour(X, Y, Z, levels, colors='k')

plt.clabel(contour, colors = 'k', fmt = '%2.1f', fontsize=12)

contour_filled = plt.contourf(X, Y, Z, levels)

plt.colorbar(contour_filled)

plt.title('Plot from level list')

plt.xlabel('x (cm)')

plt.ylabel('y (cm)')

plt.show()