06.3.15
See retention at a glance with a cohort heatmap For retention analysis, a heatmap that lists acquisition cohorts by elapsed months is a reliable staple. Vertical or horizontal bands often hint at specific period issues.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
cohorts = [ "2024-01" , "2024-02" , "2024-03" , "2024-04" , "2024-05" , "2024-06" ]
months = [ f "Month { m } " for m in range ( 1 , 7 )]
rng = np . random . default_rng ( 21 )
base = np . linspace ( 0.7 , 0.4 , num = 6 )
matrix = np . vstack (
[
np . clip ( base - idx * 0.03 + rng . normal ( 0 , 0.01 , size = base . size ), 0.1 , 0.9 )
for idx in range ( len ( cohorts ))
]
)
fig , ax = plt . subplots ( figsize = ( 6.4 , 3.8 ))
im = ax . imshow ( matrix , cmap = "YlGnBu" , vmin = 0 , vmax = 1 )
ax . set_xticks ( range ( len ( months )), labels = months )
ax . set_yticks ( range ( len ( cohorts )), labels = cohorts )
ax . set_title ( "Subscription retention cohort heatmap" )
for i in range ( matrix . shape [ 0 ]):
for j in range ( matrix . shape [ 1 ]):
ax . text ( j , i , f " { matrix [ i , j ] * 100 : .0f } %" , ha = "center" , va = "center" , fontsize = 9 )
cbar = fig . colorbar ( im , ax = ax , fraction = 0.045 , pad = 0.02 )
cbar . set_label ( "Retention rate" )
ax . set_xlabel ( "Months since acquisition" )
ax . set_ylabel ( "Acquisition cohort" )
fig . tight_layout ()
plt . show ()
Reading tips
# If a specific cohort drops sharply, the acquisition month may have quality issues. Horizontal shifts suggest product lifecycle problems affecting all cohorts. Add percentage labels to avoid relying on color alone. Learning navigator
PHASE 4 · Applications
Mark pages as read to see your progress on the home page and section lists (stored only in your browser).