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.04118444, 0.48230177, 0.77927918, 0.29254642, 0.73980109, 0.49963108, 0.04863297, 0.59662692, 0.33878457, 0.31809573], [0.52133695, 0.60959282, 0.8622425 , 0.71564676, 0.2159583 , 0.71012477, 0.90662115, 0.87052108, 0.77252615, 0.41595434], [0.32217113, 0.24422752, 0.69101378, 0.29966596, 0.29062049, 0.54149556, 0.33982777, 0.89104372, 0.22147069, 0.29637125], [0.65635182, 0.84869698, 0.12616152, 0.85987776, 0.7900953 , 0.1012453 , 0.65812368, 0.65808063, 0.41213371, 0.7773544 ], [0.9514583 , 0.44711209, 0.7069264 , 0.07081671, 0.96454892, 0.75516074, 0.78404516, 0.63436925, 0.95594211, 0.56967467], [0.1226608 , 0.51701017, 0.6557144 , 0.46153966, 0.15237046, 0.66569414, 0.83815729, 0.57583544, 0.07577363, 0.82676996], [0.71161468, 0.23399647, 0.40221656, 0.96230508, 0.57064054, 0.30194774, 0.14286738, 0.1474279 , 0.25554653, 0.47405697], [0.75738332, 0.79951314, 0.0274631 , 0.82167951, 0.10689381, 0.92363213, 0.2783303 , 0.70285459, 0.33370071, 0.92493375], [0.55750725, 0.81187001, 0.13888159, 0.65316733, 0.89245864, 0.73618519, 0.58875127, 0.34669812, 0.62498963, 0.72760351], [0.13110088, 0.32140094, 0.77764596, 0.19152845, 0.62331079, 0.10532949, 0.86776041, 0.54175429, 0.5700452 , 0.47285224]])

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>