Open mucmch opened 1 year ago
I can't replicate this with the following versions
seaborn 0.13.0.dev0
matplotlib 3.7.0
What version of matplotlib are you using? Can you try on the most recent released versions of seaborn / matplotlib?
I found the culprit. The 'figure.constrained_layout.use' was still activated in the background. Probably some explicit enabling and disabling or at least some explicit error handling would be helpful.
The error can be reproduced like:
import matplotlib as mpl
import numpy as np
from seaborn.matrix import clustermap
data = np.random.randn(300, 300)
mpl.rcParams['figure.constrained_layout.use'] = True
grid = clustermap(data)
Ah, I see. Yeah; could probably avoid it using this: https://github.com/mwaskom/seaborn/blob/242a3312b6742f5b255c7ad6bccb7228839c9419/seaborn/utils.py#L852
(Although I think this needs to be expanded to include the newer layout-related parameters).
I have the same problem using constrained_layout
. However, using tight_layout
(rcParams['figure.autolayout'] = True
) works without any errors.
Given constrained_layout
supposed to be a more flexible version of tight_layout
and handles colorbars placed on multiple Axes, maybe we can narrow down and just debug around that code section?
When running the following sample code in a Jupyter Notebook, there is a RuntimeError. However, it is highly dependent on the cell order within the Jupyter Notebook.
Environment:
Jupyter notebook server: 6.5.2 Python 3.10.8 IPython 8.8.0 Seaborn: 0.11.2
Sample Code:
Error Stack