<p dir="auto">Hello,</p>
<p dir="auto">I discovered that my Seaborn-dependent package gets, as far as I can tell, eternally stuck when creating a displot histogram if using Seaborn==0.11.2 (matplotlib==3.4.2). Everything functions as intended on Seaborn v0.11.0 and 0.11.1.</p>
<p dir="auto">While solving the issue, I narrowed the problem down to <strong>row 400 of distributions.py plot_univariate_histogram()</strong>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="all_data = self.comp_data.dropna()"><pre class="notranslate"><span class="pl-s1">all_data</span> <span class="pl-c1">=</span> <span class="pl-s1">self</span>.<span class="pl-s1">comp_data</span>.<span class="pl-en">dropna</span>()</pre></div>
<p dir="auto">I was not able to view contents of self.comp_data on PyCharm's debugger, so that's the likely culprit.</p>
<p dir="auto">Furthermore, I tested that the problem occurs with a melted &amp; merged Data Frame that <strong>has repeated indices</strong>. Resetting of the index solves the problem and the distributions are plotted within seconds. While altering my code solved this for me, I bring this to your attention as I feel like this (at least the Python getting stuck part) is not intended.</p>
<h3 dir="auto">Data and code</h3>
<p dir="auto">Note: '<em>Old ind</em>' are the indices before resetting, and '<em>Reset ind</em>' after reset.</p>
<table role="table">
<thead>
<tr>
<th>Reset ind</th>
<th>Old ind</th>
<th>Channel</th>
<th>DistBin</th>
<th>Sample Group</th>
<th>Type</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>0</td>
<td>DAPI10x</td>
<td>0</td>
<td>Ctrl</td>
<td>Area</td>
<td>31.2650</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>DAPI10x</td>
<td>0</td>
<td>Ctrl</td>
<td>Area</td>
<td>24.9275</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>DAPI10x</td>
<td>0</td>
<td>Ctrl</td>
<td>Area</td>
<td>81.1201</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>DAPI10x</td>
<td>0</td>
<td>Ctrl</td>
<td>Area</td>
<td>49.4325</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>DAPI10x</td>
<td>0</td>
<td>Ctrl</td>
<td>Area</td>
<td>22.3925</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>1596983</td>
<td>40167</td>
<td>DAPI10x</td>
<td>61</td>
<td>MutB</td>
<td>Volume</td>
<td>287.5537</td>
</tr>
<tr>
<td>1596984</td>
<td>40168</td>
<td>DAPI10x</td>
<td>61</td>
<td>MutB</td>
<td>Volume</td>
<td>287.5537</td>
</tr>
<tr>
<td>1596985</td>
<td>40169</td>
<td>DAPI10x</td>
<td>61</td>
<td>MutB</td>
<td>Volume</td>
<td>349.9147</td>
</tr>
<tr>
<td>1596986</td>
<td>40170</td>
<td>DAPI10x</td>
<td>61</td>
<td>MutB</td>
<td>Volume</td>
<td>453.8498</td>
</tr>
<tr>
<td>1596987</td>
<td>40171</td>
<td>DAPI10x</td>
<td>61</td>
<td>MutB</td>
<td>Volume</td>
<td>204.4056</td>
</tr>
</tbody>
</table>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="row_order = data.loc[:, 'Type'].unique()
plot_palette = {'Ctrl': (0.39215686274509803, 0.5333333333333333, 0.9176470588235294),
                'MutB': (0.9803921568627451, 0.7607843137254902, 0.0196078431372549)}

sns.displot(data=data, x='Value', hue='Sample Group', col=None, row='Type', alpha=0.4, kind='hist',
            stat='probability', palette=plot_palette, kde=True, height=2.5, aspect=2.25,
            row_order=row_order, discrete=False, multiple='stack',
            facet_kws={'legend_out': True, 'sharex': False, 'sharey': False,
                       'gridspec_kws': {'top': 0.92, 'left': 0.15, 'right': 0.8, 'hspace': 0.6}}
            )"><pre class="notranslate"><span class="pl-s1">row_order</span> <span class="pl-c1">=</span> <span class="pl-s1">data</span>.<span class="pl-s1">loc</span>[:, <span class="pl-s">'Type'</span>].<span class="pl-en">unique</span>()
<span class="pl-s1">plot_palette</span> <span class="pl-c1">=</span> {<span class="pl-s">'Ctrl'</span>: (<span class="pl-c1">0.39215686274509803</span>, <span class="pl-c1">0.5333333333333333</span>, <span class="pl-c1">0.9176470588235294</span>),
                <span class="pl-s">'MutB'</span>: (<span class="pl-c1">0.9803921568627451</span>, <span class="pl-c1">0.7607843137254902</span>, <span class="pl-c1">0.0196078431372549</span>)}

<span class="pl-s1">sns</span>.<span class="pl-en">displot</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">data</span>, <span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s">'Value'</span>, <span class="pl-s1">hue</span><span class="pl-c1">=</span><span class="pl-s">'Sample Group'</span>, <span class="pl-s1">col</span><span class="pl-c1">=</span><span class="pl-c1">None</span>, <span class="pl-s1">row</span><span class="pl-c1">=</span><span class="pl-s">'Type'</span>, <span class="pl-s1">alpha</span><span class="pl-c1">=</span><span class="pl-c1">0.4</span>, <span class="pl-s1">kind</span><span class="pl-c1">=</span><span class="pl-s">'hist'</span>,
            <span class="pl-s1">stat</span><span class="pl-c1">=</span><span class="pl-s">'probability'</span>, <span class="pl-s1">palette</span><span class="pl-c1">=</span><span class="pl-s1">plot_palette</span>, <span class="pl-s1">kde</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, <span class="pl-s1">height</span><span class="pl-c1">=</span><span class="pl-c1">2.5</span>, <span class="pl-s1">aspect</span><span class="pl-c1">=</span><span class="pl-c1">2.25</span>,
            <span class="pl-s1">row_order</span><span class="pl-c1">=</span><span class="pl-s1">row_order</span>, <span class="pl-s1">discrete</span><span class="pl-c1">=</span><span class="pl-c1">False</span>, <span class="pl-s1">multiple</span><span class="pl-c1">=</span><span class="pl-s">'stack'</span>,
            <span class="pl-s1">facet_kws</span><span class="pl-c1">=</span>{<span class="pl-s">'legend_out'</span>: <span class="pl-c1">True</span>, <span class="pl-s">'sharex'</span>: <span class="pl-c1">False</span>, <span class="pl-s">'sharey'</span>: <span class="pl-c1">False</span>,
                       <span class="pl-s">'gridspec_kws'</span>: {<span class="pl-s">'top'</span>: <span class="pl-c1">0.92</span>, <span class="pl-s">'left'</span>: <span class="pl-c1">0.15</span>, <span class="pl-s">'right'</span>: <span class="pl-c1">0.8</span>, <span class="pl-s">'hspace'</span>: <span class="pl-c1">0.6</span>}}
            )</pre></div>
<p dir="auto">I am using <code class="notranslate">histplot</code> for plotting simple histogram plots for medium sized data-sizes.</p>
<p dir="auto">I was using <code class="notranslate">histplot</code> for histogram determinations in my dataset using 0.11.1 and all worked very nicely and fast.</p>
<p dir="auto">Then upon upgrading to 0.11.2 it suddenly never finishes and I am stuck in plotting stuff...</p>
<p dir="auto">I have a plotting script looking like this:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="plt.figure()
sns.histplot(data=df, x=&quot;AllocCores&quot;, binwidth=1, discrete=True, log_scale=(False, True))"><pre class="notranslate"><span class="pl-s1">plt</span>.<span class="pl-en">figure</span>()
<span class="pl-s1">sns</span>.<span class="pl-en">histplot</span>(<span class="pl-s1">data</span><span class="pl-c1">=</span><span class="pl-s1">df</span>, <span class="pl-s1">x</span><span class="pl-c1">=</span><span class="pl-s">"AllocCores"</span>, <span class="pl-s1">binwidth</span><span class="pl-c1">=</span><span class="pl-c1">1</span>, <span class="pl-s1">discrete</span><span class="pl-c1">=</span><span class="pl-c1">True</span>, <span class="pl-s1">log_scale</span><span class="pl-c1">=</span>(<span class="pl-c1">False</span>, <span class="pl-c1">True</span>))</pre></div>
<p dir="auto">The data-frame has 789412 entries and the span of the data <code class="notranslate">df["AllocCores"].min / max</code> is <code class="notranslate">1, 1200</code>. So 1200 bins which I agree is very large but required in our analysis plots ;)</p>
<p dir="auto">Using <strong>0.11.1</strong> I get this:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$&gt; time python script.py
seaborn version = 0.11.1
Starting to plot...
Choosing binwidth = 120
Choosing binwidth = 1070
Choosing binwidth = 16
Choosing binwidth = 16
python script.py  40.34s user 0.83s system 155% cpu 26.479 total"><pre class="notranslate">$<span class="pl-k">&gt;</span> <span class="pl-k">time</span> python script.py
seaborn version = 0.11.1
Starting to plot...
Choosing binwidth = 120
Choosing binwidth = 1070
Choosing binwidth = 16
Choosing binwidth = 16
python script.py  40.34s user 0.83s system 155% cpu 26.479 total</pre></div>
<p dir="auto">note that this is plotting 16 files in less than a minute.</p>
<p dir="auto">Using <strong>0.11.2</strong> I get this:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="$&gt; time python script.py
seaborn version = 0.11.2
Starting to plot..."><pre class="notranslate">$<span class="pl-k">&gt;</span> <span class="pl-k">time</span> python script.py
seaborn version = 0.11.2
Starting to plot...</pre></div>
<p dir="auto">it basically never ends... I have waited more than 10 minutes, but it isn't even done with the 1st plot.</p>
<p dir="auto">When killing it <code class="notranslate">Ctrl+^C</code> I get this stack-trace:</p>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="  File &quot;script.py&quot;, line 96, in &lt;module&gt;
    plot_alloccores(df)
  File &quot;.../script_lib.py&quot;, line 98, in plot_alloccores
    sns.histplot(data=df, x=&quot;AllocCores&quot;, binwidth=1, discrete=True, log_scale=(False, True))
  File &quot;/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/distributions.py&quot;, line 1462, in histplot
    p.plot_univariate_histogram(
  File &quot;/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/distributions.py&quot;, line 428, in plot_univariate_histogram
    for sub_vars, sub_data in self.iter_data(&quot;hue&quot;, from_comp_data=True):
  File &quot;/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/_core.py&quot;, line 983, in iter_data
    data = self.comp_data
  File &quot;/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/_core.py&quot;, line 1057, in comp_data
    comp_col.loc[orig.index] = pd.to_numeric(axis.convert_units(orig))
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexing.py&quot;, line 671, in __setitem__
    self._setitem_with_indexer(indexer, value)
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexing.py&quot;, line 1055, in _setitem_with_indexer
    value = self._align_series(indexer, Series(value))
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexing.py&quot;, line 1173, in _align_series
    ser = ser.reindex(obj.axes[0][indexer[0]], copy=True)._values
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/series.py&quot;, line 4030, in reindex
    return super().reindex(index=index, **kwargs)
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/generic.py&quot;, line 4543, in reindex
    return self._reindex_axes(
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/generic.py&quot;, line 4558, in _reindex_axes
    new_index, indexer = ax.reindex(
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexes/base.py&quot;, line 3153, in reindex
    indexer, missing = self.get_indexer_non_unique(target)
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexes/base.py&quot;, line 4486, in get_indexer_non_unique
    indexer, missing = self._engine.get_indexer_non_unique(tgt_values)
  File &quot;pandas/_libs/index.pyx&quot;, line 354, in pandas._libs.index.IndexEngine.get_indexer_non_unique
  File &quot;&lt;__array_function__ internals&gt;&quot;, line 5, in resize
  File &quot;/opt/gnu/9.3.0/python/packages/3.8.5/numpy/1.19.1/lib/python3.8/site-packages/numpy-1.19.1-py3.8-linux-x86_64.egg/numpy/core/fromnumeric.py&quot;, line 1417, in resize
    a = concatenate((a,) * n_copies)
  File &quot;&lt;__array_function__ internals&gt;&quot;, line 5, in concatenate
KeyboardInterrupt"><pre class="notranslate">  File <span class="pl-s"><span class="pl-pds">"</span>script.py<span class="pl-pds">"</span></span>, line 96, <span class="pl-k">in</span> <span class="pl-k">&lt;</span>module<span class="pl-k">&gt;</span>
    plot_alloccores(df)
  File <span class="pl-s"><span class="pl-pds">"</span>.../script_lib.py<span class="pl-pds">"</span></span>, line 98, <span class="pl-k">in</span> plot_alloccores
    sns.histplot(data=df, x=<span class="pl-s"><span class="pl-pds">"</span>AllocCores<span class="pl-pds">"</span></span>, binwidth=1, discrete=True, log_scale=(False, True))
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/distributions.py<span class="pl-pds">"</span></span>, line 1462, <span class="pl-k">in</span> histplot
    p.plot_univariate_histogram(
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/distributions.py<span class="pl-pds">"</span></span>, line 428, <span class="pl-k">in</span> plot_univariate_histogram
    <span class="pl-k">for</span> <span class="pl-smi">sub_vars, sub_data</span> <span class="pl-k">in</span> self.iter_data(<span class="pl-s"><span class="pl-pds">"</span>hue<span class="pl-pds">"</span></span>, from_comp_data=True):
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/_core.py<span class="pl-pds">"</span></span>, line 983, <span class="pl-k">in</span> iter_data
    data = self.comp_data
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/3.8.5/lib/python3.8/site-packages/seaborn/_core.py<span class="pl-pds">"</span></span>, line 1057, <span class="pl-k">in</span> comp_data
    comp_col.loc[orig.index] = pd.to_numeric(axis.convert_units(orig))
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexing.py<span class="pl-pds">"</span></span>, line 671, <span class="pl-k">in</span> __setitem__
    self._setitem_with_indexer(indexer, value)
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexing.py<span class="pl-pds">"</span></span>, line 1055, <span class="pl-k">in</span> _setitem_with_indexer
    value = self._align_series(indexer, Series(value))
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexing.py<span class="pl-pds">"</span></span>, line 1173, <span class="pl-k">in</span> _align_series
    ser = ser.reindex(obj.axes[0][indexer[0]], copy<span class="pl-k">=</span>True)._values
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/series.py<span class="pl-pds">"</span></span>, line 4030, <span class="pl-k">in</span> reindex
    <span class="pl-k">return</span> <span class="pl-en">super</span>().reindex(index=index, <span class="pl-k">**</span>kwargs)
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/generic.py<span class="pl-pds">"</span></span>, line 4543, <span class="pl-k">in</span> reindex
    <span class="pl-k">return</span> self._reindex_axes(
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/generic.py<span class="pl-pds">"</span></span>, line 4558, <span class="pl-k">in</span> _reindex_axes
    new_index, indexer = ax.reindex(
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexes/base.py<span class="pl-pds">"</span></span>, line 3153, <span class="pl-k">in</span> reindex
    indexer, missing = self.get_indexer_non_unique(target)
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/pandas/1.0.5/lib/python3.8/site-packages/pandas-1.0.5-py3.8-linux-x86_64.egg/pandas/core/indexes/base.py<span class="pl-pds">"</span></span>, line 4486, <span class="pl-k">in</span> get_indexer_non_unique
    indexer, missing = self._engine.get_indexer_non_unique(tgt_values)
  File <span class="pl-s"><span class="pl-pds">"</span>pandas/_libs/index.pyx<span class="pl-pds">"</span></span>, line 354, <span class="pl-k">in</span> pandas._libs.index.IndexEngine.get_indexer_non_unique
  File <span class="pl-s"><span class="pl-pds">"</span>&lt;__array_function__ internals&gt;<span class="pl-pds">"</span></span>, line 5, <span class="pl-k">in</span> resize
  File <span class="pl-s"><span class="pl-pds">"</span>/opt/gnu/9.3.0/python/packages/3.8.5/numpy/1.19.1/lib/python3.8/site-packages/numpy-1.19.1-py3.8-linux-x86_64.egg/numpy/core/fromnumeric.py<span class="pl-pds">"</span></span>, line 1417, <span class="pl-k">in</span> resize
    a = concatenate<span class="pl-s"><span class="pl-pds">((</span>a<span class="pl-k">,</span>) <span class="pl-k">*</span> n_copies)</span>
<span class="pl-s">  File "&lt;__array_function__ internals&gt;", line <span class="pl-c1">5</span>, in concatenate</span>
<span class="pl-s">KeyboardInterrupt</span></pre></div>
<p dir="auto">I hope that this can provide enough details for finding the regression, if not and you require some kind of data-set, let me know and I'll try to cook something out. There is some sensitive data that I can't share. But I may be able to fiddle with the entries if this may aid?</p>