<p dir="auto">Hi <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mwaskom/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mwaskom">@mwaskom</a> ,</p>
<p dir="auto">I raised an issue regarding importing seaborn error <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="234840117" data-permission-text="Title is private" data-url="https://github.com/mwaskom/seaborn/issues/1200" data-hovercard-type="issue" data-hovercard-url="/mwaskom/seaborn/issues/1200/hovercard" href="https://github.com/mwaskom/seaborn/issues/1200">#1200</a><br>
while trying to run the flask application in IIS server. However since I couldn't provide much information at that time you couldn't help me. Sorry for late reply.</p>
<p dir="auto">But I tried to log the traceback error caused due to importing seaborn. Results are below. Any help regarding this?</p>
<p dir="auto">Traceback (most recent call last):<br>
File ".\test.py", line 62, in<br>
import seaborn as sns<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\seaborn_init_.py", line 16, in<br>
from .widgets import *<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\seaborn\widgets.py", line 8, in<br>
from ipywidgets import interact, FloatSlider, IntSlider<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\ipywidgets_init_.py", line 23, in<br>
from IPython import get_ipython<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython_init_.py", line 49, in<br>
from .terminal.embed import embed<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\terminal\embed.py", line 17, in<br>
from IPython.core.interactiveshell import DummyMod, InteractiveShell<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 62, in<br>
from IPython.utils import io<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\io.py", line 97, in<br>
stdin = IOStream(sys.stdin, fallback=devnull)<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\io.py", line 41, in init<br>
for meth in filter(clone, dir(stream)):<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\io.py", line 40, in clone<br>
return not hasattr(self, meth) and not meth.startswith('_')<br>
File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\utils\io.py", line 84, in closed<br>
return self.stream.closed<br>
ValueError: underlying buffer has been detached</p>
<p dir="auto">Eagerly waiting for your insights into this.</p>
<p dir="auto">I'm fairly certain that I found a bug; though it could be user error on my part. If this is a known issue, please feel free to close :)</p>
<p dir="auto">Minimal Code:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

# technically not necessary, but looks nicer :)
sns.set_context(&quot;talk&quot;)

df = pd.DataFrame({&quot;A&quot;: [&quot;foo&quot;, &quot;foo&quot;, &quot;foo&quot;, &quot;foo&quot;, &quot;foo&quot;,
                         &quot;bar&quot;, &quot;bar&quot;, &quot;bar&quot;, &quot;bar&quot;],
                   &quot;B&quot;: [&quot;1&quot;, &quot;1&quot;, &quot;1&quot;, &quot;2&quot;, &quot;2&quot;,
                         &quot;1&quot;, &quot;1&quot;, &quot;2&quot;, &quot;2&quot;],
                   &quot;C&quot;: [&quot;small&quot;, &quot;large&quot;, &quot;large&quot;, &quot;small&quot;,
                         &quot;small&quot;, &quot;large&quot;, &quot;small&quot;, &quot;small&quot;,
                         &quot;large&quot;],
                   &quot;D&quot;: [1, 2, 2, 3, 3, 4, 5, 6, 7],
                   &quot;E&quot;: [2, 4, 5, 5, 6, 6, 8, 9, 9]})

table = pd.pivot_table(df, values='D', index=['A', 'B'],
                    columns=['C'], aggfunc=np.sum)

fig, ax = plt.subplots()
sns.heatmap(table, fmt=&quot;.2f&quot;, cmap=sns.diverging_palette(230, 20, as_cmap=True), ax=ax)

plt.show()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">seaborn</span> <span class="pl-k">as</span> <span class="pl-s1">sns</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>

<span class="pl-c"># technically not necessary, but looks nicer :)</span>
<span class="pl-s1">sns</span>.<span class="pl-en">set_context</span>(<span class="pl-s">"talk"</span>)

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>({<span class="pl-s">"A"</span>: [<span class="pl-s">"foo"</span>, <span class="pl-s">"foo"</span>, <span class="pl-s">"foo"</span>, <span class="pl-s">"foo"</span>, <span class="pl-s">"foo"</span>,
                         <span class="pl-s">"bar"</span>, <span class="pl-s">"bar"</span>, <span class="pl-s">"bar"</span>, <span class="pl-s">"bar"</span>],
                   <span class="pl-s">"B"</span>: [<span class="pl-s">"1"</span>, <span class="pl-s">"1"</span>, <span class="pl-s">"1"</span>, <span class="pl-s">"2"</span>, <span class="pl-s">"2"</span>,
                         <span class="pl-s">"1"</span>, <span class="pl-s">"1"</span>, <span class="pl-s">"2"</span>, <span class="pl-s">"2"</span>],
                   <span class="pl-s">"C"</span>: [<span class="pl-s">"small"</span>, <span class="pl-s">"large"</span>, <span class="pl-s">"large"</span>, <span class="pl-s">"small"</span>,
                         <span class="pl-s">"small"</span>, <span class="pl-s">"large"</span>, <span class="pl-s">"small"</span>, <span class="pl-s">"small"</span>,
                         <span class="pl-s">"large"</span>],
                   <span class="pl-s">"D"</span>: [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>, <span class="pl-c1">7</span>],
                   <span class="pl-s">"E"</span>: [<span class="pl-c1">2</span>, <span class="pl-c1">4</span>, <span class="pl-c1">5</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>, <span class="pl-c1">6</span>, <span class="pl-c1">8</span>, <span class="pl-c1">9</span>, <span class="pl-c1">9</span>]})

<span class="pl-s1">table</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">pivot_table</span>(<span class="pl-s1">df</span>, <span class="pl-s1">values</span><span class="pl-c1">=</span><span class="pl-s">'D'</span>, <span class="pl-s1">index</span><span class="pl-c1">=</span>[<span class="pl-s">'A'</span>, <span class="pl-s">'B'</span>],
                    <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">'C'</span>], <span class="pl-s1">aggfunc</span><span class="pl-c1">=</span><span class="pl-s1">np</span>.<span class="pl-s1">sum</span>)

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()
<span class="pl-s1">sns</span>.<span class="pl-en">heatmap</span>(<span class="pl-s1">table</span>, <span class="pl-s1">fmt</span><span class="pl-c1">=</span><span class="pl-s">".2f"</span>, <span class="pl-s1">cmap</span><span class="pl-c1">=</span><span class="pl-s1">sns</span>.<span class="pl-en">diverging_palette</span>(<span class="pl-c1">230</span>, <span class="pl-c1">20</span>, <span class="pl-s1">as_cmap</span><span class="pl-c1">=</span><span class="pl-c1">True</span>), <span class="pl-s1">ax</span><span class="pl-c1">=</span><span class="pl-s1">ax</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto">Produces:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/4402489/119463376-90aa7900-bcf6-11eb-921d-bfa734301d4c.png"><img src="https://user-images.githubusercontent.com/4402489/119463376-90aa7900-bcf6-11eb-921d-bfa734301d4c.png" alt="bug" style="max-width: 100%;"></a></p>
<p dir="auto">Which has misaligned labels along the y-axis. If the labels get longer, seaborn seems to automatically rotate them, in which case the problem disappears.</p>
<p dir="auto">Version Info:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Python 3.8.8
seaborn==0.11.1
matplotlib==3.3.4"><pre class="notranslate"><code class="notranslate">Python 3.8.8
seaborn==0.11.1
matplotlib==3.3.4
</code></pre></div>