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.43316776, 0.39353484, 0.97483009, 0.61494796, 0.56876993, 0.94039135, 0.32405918, 0.67341001, 0.7145224 , 0.88870438], [0.65631463, 0.0114088 , 0.49560791, 0.94149271, 0.35522875, 0.97415045, 0.1905303 , 0.44055923, 0.99582417, 0.40621127], [0.74750705, 0.95654275, 0.6298601 , 0.83475939, 0.59197873, 0.8343503 , 0.12170318, 0.13593435, 0.07591825, 0.61241249], [0.44098068, 0.23590032, 0.99637269, 0.84430254, 0.26913565, 0.86166857, 0.25656238, 0.00643176, 0.13637722, 0.34569035], [0.13751147, 0.99939894, 0.83398341, 0.01407892, 0.54442732, 0.21141505, 0.67620119, 0.65425754, 0.32038434, 0.3493195 ], [0.51779573, 0.09566911, 0.60497915, 0.56341415, 0.25663898, 0.34158455, 0.13056627, 0.98340256, 0.25628592, 0.19505072], [0.33355701, 0.55131071, 0.64465359, 0.62152009, 0.82185174, 0.53110537, 0.21162086, 0.80211681, 0.81901536, 0.17985918], [0.73761429, 0.76453627, 0.93165346, 0.59258915, 0.62765644, 0.33321461, 0.77872328, 0.63050886, 0.4451151 , 0.79010324], [0.49786208, 0.85892233, 0.9112973 , 0.87630469, 0.84929183, 0.1050377 , 0.36960976, 0.56940617, 0.65462979, 0.86905418], [0.14137858, 0.32620738, 0.5446265 , 0.97313979, 0.07527332, 0.14898385, 0.62220887, 0.99329235, 0.16430819, 0.1483555 ]])

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>