import numpy as np import matplotlib.pyplot as plt length = 20 grid = np.ones((length, length), dtype=float) x = np.arange(length) y = np.arange(length) grid[x, y] = 0.5 grid[x, y[::-1]] = 0.5 grid[x[::-1], y[::-1]] = 0.5 grid[x[::-1], y] = 0.5 x = range(length) y = x plt.contourf(x, y, grid, levels=[0, 0.25, 0.5, 0.75, 1., 1.25]) plt.pcolormesh(grid)