Skip to content

Fix FixedLocator/labels mismatch in create_heatmap for large matrices - #29

Merged
elementare merged 1 commit into
mainfrom
fix/heatmap-fixedlocator-bug
Sep 29, 2026
Merged

elementare merged 1 commit into
mainfrom
fix/heatmap-fixedlocator-bug

Conversation

@riveros94

Copy link
Copy Markdown
Contributor

sns.clustermap's tick locator only reliably matches the cell count once the matrix is large enough (~40+ categories); below that it happens to work. Explicitly fix the x/y tick positions to cell centers (offset by 0.5, matching clustermap's own convention) before assigning labels, so set_xticklabels/set_yticklabels always see a matching tick count.

Confirmed the crash empirically with 44 and 48 structures; 21 worked fine before this fix.

Also scale figsize with the number of structures and drop the per-cell numeric annotations past 50 structures: with the crash fixed, larger matrices (100+) still rendered with illegible overlapping labels and cell text, since the figure size was previously fixed regardless of matrix size.

sns.clustermap's tick locator only reliably matches the cell count once
the matrix is large enough (~40+ categories); below that it happens to
work. Explicitly fix the x/y tick positions to cell centers (offset by
0.5, matching clustermap's own convention) before assigning labels, so
set_xticklabels/set_yticklabels always see a matching tick count.

Confirmed the crash empirically with 44 and 48 structures; 21 worked
fine before this fix.

Also scale figsize with the number of structures and drop the per-cell
numeric annotations past 50 structures: with the crash fixed, larger
matrices (100+) still rendered with illegible overlapping labels and
cell text, since the figure size was previously fixed regardless of
matrix size.
@elementare
elementare merged commit e536dc6 into main Sep 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants