Skip to article frontmatterSkip to article content

A basic example

This is a basic notebook example

First we create a numpy random matrix

import numpy as np

matrix = np.random.rand(10,10)
matrix
array([[5.20309758e-01, 2.93620334e-01, 7.43913941e-01, 7.75048896e-01, 2.38048031e-01, 1.67684622e-01, 4.55827644e-02, 5.54867537e-01, 7.24565229e-02, 9.21174087e-02], [7.67235795e-01, 7.91286842e-01, 8.72532821e-01, 4.54853191e-01, 9.36959701e-01, 4.25119220e-01, 2.67934369e-01, 3.76569307e-02, 2.56254672e-01, 5.47140331e-01], [7.61946024e-01, 6.72934622e-01, 9.72435179e-03, 1.09459584e-01, 4.48555281e-01, 3.50447577e-01, 6.78170291e-01, 4.29262252e-01, 5.82903322e-01, 1.96952952e-01], [7.57597065e-01, 4.40856001e-01, 1.35524617e-01, 1.39478609e-01, 9.99890155e-02, 8.33104628e-01, 1.12550722e-01, 6.00644463e-01, 6.55434239e-01, 9.97959392e-02], [7.40531519e-01, 9.08258031e-01, 9.43250991e-01, 2.59500291e-01, 3.19301490e-01, 5.58799785e-01, 8.28746810e-02, 6.83511696e-01, 8.16058482e-01, 5.10510272e-01], [2.72907626e-01, 9.41031496e-01, 8.52562564e-01, 9.37945958e-01, 9.78145752e-01, 1.28919786e-01, 4.56063010e-01, 2.26282458e-01, 5.87132997e-01, 7.57750038e-02], [9.21793940e-01, 5.21445236e-01, 8.48233449e-02, 5.52774061e-01, 6.49684326e-01, 8.78639588e-01, 5.79374761e-01, 9.16230939e-01, 8.55940335e-01, 9.02147136e-01], [7.29568468e-01, 2.66582641e-01, 8.25638390e-01, 9.43695525e-01, 8.57098199e-01, 4.06817671e-01, 9.78773219e-01, 4.41604218e-01, 7.59500430e-02, 8.11576543e-01], [2.40128637e-01, 6.22908290e-01, 2.07653598e-01, 9.94941397e-01, 4.85076287e-01, 8.19911995e-01, 6.98947415e-02, 6.39969982e-02, 7.17100339e-01, 7.36022457e-01], [4.80511838e-01, 2.41801203e-02, 5.99803524e-01, 2.68013448e-01, 6.76646129e-01, 1.83002691e-01, 1.77759021e-05, 4.72048868e-01, 4.06191957e-02, 1.52702286e-01]])

Convert it into a pandas dataframe

import pandas as pd

df_matrix = pd.DataFrame(matrix)
df_matrix
Loading...

Plot a heatmap

%matplotlib inline
import matplotlib.pyplot as plt

plt.pcolor(df_matrix)
plt.show()
<Figure size 640x480 with 1 Axes>