Heatmap and colorbar

In [32]:
# Import needed packages
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
import numpy as np

# Create array with random data
array = np.random.uniform(low=-1, high=1, size=10000).reshape(100, 100)

# Generate the figure
figure(figsize=(16,16))
plt.imshow(array, cmap='viridis', interpolation='nearest')
plt.xticks([])
plt.yticks([])

# Generate the color bar
plt.colorbar()
plt.clim(-1, 1)

# Show figure
plt.show()