Creating an imageΒΆ

How to create an image with basic NumPy commands : np.zeros, slicing...

This examples show how to create a simple checkerboard.

../../../_images/plot_check_1.png

Python source code: plot_check.py

import numpy as np
import matplotlib.pyplot as plt
check = np.zeros((9, 9))
check[::2, 1::2] = 1
check[1::2, ::2] = 1
plt.matshow(check, cmap='gray')
plt.show()

Total running time of the example: 0.04 seconds ( 0 minutes 0.04 seconds)