title: How to arrange y-labels in seaborn clustermap when using a multiindex dataframe?
body: <p>I am trying to customize y-labels of a clustermap from seaborn with a multiindex dataframe. So I have a dataframe that looks like this :</p>
  <pre><code>                    Col1    Col2    ...
  Idx1.A    Idx2.a    1.05    1.51    ...
            Idx2.b    0.94    0.88    ...
  Idx1.B    Idx2.c    1.09    1.20    ...
            Idx2.d    0.90    0.79    ...
     ...       ...     ...     ...    ...
  </code></pre>
  <p>The goal is to have the same y-labels like that, where in my example Idx1 would be the seasons, Idx2 would be the months and the Cols would be the years (except that it's a clustermap, not a heatmap - so I think the functions from the seaborn classes are different when customizing the ticks -, though clustermap just &quot;add&quot; a hierarchic clustering on a heatmap over rows or columns):
  <a href="https://i.stack.imgur.com/NXJHs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NXJHs.png" alt="enter image description here" /></a>
  My code :</p>
  <pre><code>def do_clustermap():
      with open('/home/Documents/myfile.csv', 'r') as f:
          df = pd.read_csv(f, index_col=[0, 1], sep='\t')
  
          g = sns.clustermap(df, center=1, row_cluster=False, cmap=&quot;YlGnBu&quot;, yticklabels=True, xticklabels=True, linewidths=0.004)
          g.ax_heatmap.yaxis.set_ticks_position(&quot;left&quot;)
  
          plt.setp(g.ax_heatmap.xaxis.get_majorticklabels(), fontsize=4)
          plt.setp(g.ax_heatmap.yaxis.get_majorticklabels(), fontsize=4)
          plt.show()
  </code></pre>
  <p>I tried to follow the answers from this <a href="https://stackoverflow.com/questions/58854335/how-to-label-y-ticklabels-as-group-category-in-seaborn-clustermap">thread</a> but it gives this message :</p>
  <pre><code>UserWarning: Clustering large matrix with scipy. Installing `fastcluster` may give better performance.
    warnings.warn(msg)
  Traceback (most recent call last):
    File &quot;/home/ju/PycharmProjects/stage/figures.py&quot;, line 24, in &lt;module&gt;
      do_heatmap()
    File &quot;/home/ju/PycharmProjects/stage/figures.py&quot;, line 13, in do_heatmap
      ax = sns.clustermap(df, center=1, row_cluster=False, cmap=&quot;YlGnBu&quot;, yticklabels=True, xticklabels=True, linewidths=0.004)
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/_decorators.py&quot;, line 46, in inner_f
      return f(**kwargs)
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/matrix.py&quot;, line 1412, in clustermap
      tree_kws=tree_kws, **kwargs)
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/matrix.py&quot;, line 1223, in plot
      tree_kws=tree_kws)
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/matrix.py&quot;, line 1079, in plot_dendrograms
      tree_kws=tree_kws
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/_decorators.py&quot;, line 46, in inner_f
      return f(**kwargs)
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/matrix.py&quot;, line 776, in dendrogram
      label=label, rotate=rotate)
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/matrix.py&quot;, line 584, in __init__
      self.linkage = self.calculated_linkage
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/matrix.py&quot;, line 651, in calculated_linkage
      return self._calculate_linkage_scipy()
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/seaborn/matrix.py&quot;, line 620, in _calculate_linkage_scipy
      metric=self.metric)
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/scipy/cluster/hierarchy.py&quot;, line 1038, in linkage
      y = _convert_to_double(np.asarray(y, order='c'))
    File &quot;/home/ju/PycharmProjects/stage/venv/lib/python3.6/site-packages/scipy/cluster/hierarchy.py&quot;, line 1560, in _convert_to_double
      X = X.astype(np.double)
  ValueError: could not convert string to float: 'Col1'
  </code></pre>
  <p>Anyone has an idea ?
  Here a small example of the file I'm working with:</p>
  <pre><code>        Robert  Jean    Lulu
  Bar a   1.05    1.52    1.16
  Bar b   0.94    0.49    0.83
  Foo c   1.09    1.22    1.44
  Foo d   0.92    0.79    0.55
  Hop e   0.62    0.82    0.68
  Hop f   0.52    0.18    0.31
  Hop g   0.93    1.15    1.11
  </code></pre>