<p dir="auto">Hello,</p>
<p dir="auto">I'm testing PairGrid using <a href="http://stanford.edu/~mwaskom/software/seaborn/tutorial/axis_grids.html" rel="nofollow">http://stanford.edu/~mwaskom/software/seaborn/tutorial/axis_grids.html</a></p>
<p dir="auto">but this code</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

movie_user_preferences={'Jill': {'Avenger: Age of Ultron': 7.0,
  'Django Unchained': 6.5,
  'Gone Girl': 9.0,
  'Kill the Messenger': 8.0},
 'Julia': {'Avenger: Age of Ultron': 10.0,
  'Django Unchained': 6.0,
  'Gone Girl': 6.5,
  'Kill the Messenger': 6.0,
  'Zoolander': 6.5},
 'Max': {'Avenger: Age of Ultron': 7.0,
  'Django Unchained': 7.0,
  'Gone Girl': 10.0,
  'Horrible Bosses 2': 6.0,
  'Kill the Messenger': 5.0,
  'Zoolander': 10.0},
 'Robert': {'Avenger: Age of Ultron': 8.0,
  'Django Unchained': 7.0,
  'Horrible Bosses 2': 5.0,
  'Kill the Messenger': 9.0,
  'Zoolander': 9.0},
 'Sam': {'Avenger: Age of Ultron': 10.0,
  'Django Unchained': 7.5,
  'Gone Girl': 6.0,
  'Horrible Bosses 2': 3.0,
  'Kill the Messenger': 5.5,
  'Zoolander': 7.0},
 'Toby': {'Avenger: Age of Ultron': 8.5,
  'Django Unchained': 9.0,
  'Zoolander': 2.0},
 'William': {'Avenger: Age of Ultron': 6.0,
  'Django Unchained': 8.0,
  'Gone Girl': 7.0,
  'Horrible Bosses 2': 4.0,
  'Kill the Messenger': 6.5,
  'Zoolander': 4.0}}

df_movie_user_preferences = pd.DataFrame(movie_user_preferences)
df_movie_user_preferences.index.name = &quot;Movie&quot;
df_movie_user_preferences.columns.name = &quot;User&quot;
print df_movie_user_preferences

df_ratings = df_movie_user_preferences.transpose().reset_index()
df_ratings.columns.name = None

g = sns.PairGrid(df_ratings, hue=&quot;User&quot;)
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter)
g.add_legend()
plt.show()"><pre class="notranslate"><code class="notranslate">import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

movie_user_preferences={'Jill': {'Avenger: Age of Ultron': 7.0,
  'Django Unchained': 6.5,
  'Gone Girl': 9.0,
  'Kill the Messenger': 8.0},
 'Julia': {'Avenger: Age of Ultron': 10.0,
  'Django Unchained': 6.0,
  'Gone Girl': 6.5,
  'Kill the Messenger': 6.0,
  'Zoolander': 6.5},
 'Max': {'Avenger: Age of Ultron': 7.0,
  'Django Unchained': 7.0,
  'Gone Girl': 10.0,
  'Horrible Bosses 2': 6.0,
  'Kill the Messenger': 5.0,
  'Zoolander': 10.0},
 'Robert': {'Avenger: Age of Ultron': 8.0,
  'Django Unchained': 7.0,
  'Horrible Bosses 2': 5.0,
  'Kill the Messenger': 9.0,
  'Zoolander': 9.0},
 'Sam': {'Avenger: Age of Ultron': 10.0,
  'Django Unchained': 7.5,
  'Gone Girl': 6.0,
  'Horrible Bosses 2': 3.0,
  'Kill the Messenger': 5.5,
  'Zoolander': 7.0},
 'Toby': {'Avenger: Age of Ultron': 8.5,
  'Django Unchained': 9.0,
  'Zoolander': 2.0},
 'William': {'Avenger: Age of Ultron': 6.0,
  'Django Unchained': 8.0,
  'Gone Girl': 7.0,
  'Horrible Bosses 2': 4.0,
  'Kill the Messenger': 6.5,
  'Zoolander': 4.0}}

df_movie_user_preferences = pd.DataFrame(movie_user_preferences)
df_movie_user_preferences.index.name = "Movie"
df_movie_user_preferences.columns.name = "User"
print df_movie_user_preferences

df_ratings = df_movie_user_preferences.transpose().reset_index()
df_ratings.columns.name = None

g = sns.PairGrid(df_ratings, hue="User")
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter)
g.add_legend()
plt.show()
</code></pre></div>
<p dir="auto">prints</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="      User  Avenger: Age of Ultron  Django Unchained  Gone Girl  \
0     Jill                     7.0               6.5        9.0
1    Julia                    10.0               6.0        6.5
2      Max                     7.0               7.0       10.0
3   Robert                     8.0               7.0        NaN
4      Sam                    10.0               7.5        6.0
5     Toby                     8.5               9.0        NaN
6  William                     6.0               8.0        7.0

   Horrible Bosses 2  Kill the Messenger  Zoolander
0                NaN                 8.0        NaN
1                NaN                 6.0        6.5
2                  6                 5.0       10.0
3                  5                 9.0        9.0
4                  3                 5.5        7.0
5                NaN                 NaN        2.0
6                  4                 6.5        4.0"><pre class="notranslate"><code class="notranslate">      User  Avenger: Age of Ultron  Django Unchained  Gone Girl  \
0     Jill                     7.0               6.5        9.0
1    Julia                    10.0               6.0        6.5
2      Max                     7.0               7.0       10.0
3   Robert                     8.0               7.0        NaN
4      Sam                    10.0               7.5        6.0
5     Toby                     8.5               9.0        NaN
6  William                     6.0               8.0        7.0

   Horrible Bosses 2  Kill the Messenger  Zoolander
0                NaN                 8.0        NaN
1                NaN                 6.0        6.5
2                  6                 5.0       10.0
3                  5                 9.0        9.0
4                  3                 5.5        7.0
5                NaN                 NaN        2.0
6                  4                 6.5        4.0
</code></pre></div>
<p dir="auto">raises <code class="notranslate">max() arg is an empty sequence</code></p>
<p dir="auto">so I can't see legend</p>
<p dir="auto">Any idea ?</p>
<p dir="auto">Kind regards</p>
<p dir="auto">Python env:</p>
<ul dir="auto">
<li>Python: 3.6.8 x64</li>
<li>OS: Mac OSX / Linux</li>
<li>seaborn: 0.9.0</li>
<li>matplotlib: 3.1.1</li>
</ul>
<p dir="auto">The code below is not working as expected.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import seaborn as sns

outcome_labels = [&quot;Test A&quot;, &quot;Test B&quot;]

sns.heatmap(
    confusion_matrix(y_test, clf_predict),
    annot=True,
    fmt=&quot;d&quot;,
    xticklabels=outcome_labels,
    yticklabels=outcome_labels,
)"><pre class="notranslate"><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-s1">outcome_labels</span> <span class="pl-c1">=</span> [<span class="pl-s">"Test A"</span>, <span class="pl-s">"Test B"</span>]

<span class="pl-s1">sns</span>.<span class="pl-en">heatmap</span>(
    <span class="pl-en">confusion_matrix</span>(<span class="pl-s1">y_test</span>, <span class="pl-s1">clf_predict</span>),
    <span class="pl-s1">annot</span><span class="pl-c1">=</span><span class="pl-c1">True</span>,
    <span class="pl-s1">fmt</span><span class="pl-c1">=</span><span class="pl-s">"d"</span>,
    <span class="pl-s1">xticklabels</span><span class="pl-c1">=</span><span class="pl-s1">outcome_labels</span>,
    <span class="pl-s1">yticklabels</span><span class="pl-c1">=</span><span class="pl-s1">outcome_labels</span>,
)</pre></div>
<p dir="auto"><code class="notranslate">confusion_matrix</code> returns:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="array([[107,   3],
       [  3,  61]])"><pre class="notranslate"><span class="pl-en">array</span>([[<span class="pl-c1">107</span>,   <span class="pl-c1">3</span>],
       [  <span class="pl-c1">3</span>,  <span class="pl-c1">61</span>]])</pre></div>
<p dir="auto">It generate confusion matrix plot but annotations positions are out of boxes. By default they were centered in Vertical/Horizontal in the past but sth changed after last package update.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/228280/62290834-886ab500-b462-11e9-88d7-0e0caa18b550.png"><img src="https://user-images.githubusercontent.com/228280/62290834-886ab500-b462-11e9-88d7-0e0caa18b550.png" alt="heatmap" style="max-width: 100%;"></a></p>