Cohort Plot
Cohort heatmap: wraps heatmap.plot with x tick labels on top and percentage formatting.
Input is a pre-aggregated matrix (rows = cohorts, columns = periods since start); no aggregation is performed.
plot(df, cbar_label, x_label=None, y_label=None, title=None, eyebrow=None, subtitle=None, ax=None, source_text=None, percentage=True, figsize=None, colormap_style='discrete')
Plot a cohort heatmap, with period labels along the top.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Pre-aggregated cohort matrix (rows = cohorts, columns = periods). |
required |
cbar_label
|
str
|
Colorbar label. |
required |
x_label
|
str
|
X-axis label; omitted means no label. |
None
|
y_label
|
str
|
Y-axis label; omitted means no label. |
None
|
title
|
str
|
Plot title. |
None
|
eyebrow
|
str
|
Uppercase label rendered above the title. |
None
|
subtitle
|
str
|
Supporting copy rendered below the title. |
None
|
ax
|
Axes
|
Axes to plot on. |
None
|
source_text
|
str
|
Source attribution rendered at the bottom. |
None
|
percentage
|
bool
|
If True, cells must be 0-1 fractions (as from
|
True
|
figsize
|
tuple[int, int]
|
Figure size, used only when ax is None. |
None
|
colormap_style
|
(discrete, continuous)
|
Use "continuous" when retention differences between cohorts are small enough that the discrete bins lump them together. |
'discrete'
|
Returns:
| Name | Type | Description |
|---|---|---|
SubplotBase |
SubplotBase
|
The matplotlib axes object. |