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([[0.47907332, 0.42908494, 0.51762504, 0.47580666, 0.6463731 , 0.12799378, 0.68357134, 0.69795169, 0.55804872, 0.1081135 ], [0.9376818 , 0.19129113, 0.34354961, 0.14411476, 0.7284827 , 0.04255229, 0.25308855, 0.7605074 , 0.08113946, 0.30768735], [0.52554494, 0.99992984, 0.09850734, 0.62111382, 0.41807665, 0.93712049, 0.46152303, 0.32198741, 0.86246446, 0.21739778], [0.50457298, 0.21457291, 0.41194025, 0.39755076, 0.06043729, 0.39106551, 0.85388692, 0.5024635 , 0.42796802, 0.91516447], [0.54083485, 0.14566419, 0.70880756, 0.42558269, 0.38652154, 0.71519184, 0.14142733, 0.12833112, 0.19525751, 0.57708093], [0.5729575 , 0.82560363, 0.47010549, 0.95535358, 0.74658886, 0.28135218, 0.0822955 , 0.67881559, 0.41192451, 0.81285195], [0.17509184, 0.97570406, 0.67284617, 0.97217964, 0.93701586, 0.37180615, 0.20055482, 0.08771746, 0.13194359, 0.21834621], [0.24041232, 0.04088556, 0.10067178, 0.91544823, 0.20226142, 0.32450015, 0.47271739, 0.51223638, 0.69279662, 0.8684707 ], [0.45313585, 0.68941698, 0.78661547, 0.50940034, 0.8164425 , 0.86080663, 0.23397076, 0.77976573, 0.60400046, 0.92569605], [0.26155369, 0.6785283 , 0.67089865, 0.97711489, 0.68898119, 0.84041397, 0.89989632, 0.70383001, 0.92940368, 0.85561314]])

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>