title: Seaborn clustermap fixed cell size
body: <p>I am using the <a href="https://seaborn.pydata.org/generated/seaborn.clustermap.html" rel="nofollow noreferrer">seaborn clustermap</a> function and I would like to make multiple plots where the cell sizes are exactly identical. Also the size of the axis labels should be the same. This means figure size and aspect ratio will need to change, the rest needs to stay identical. </p>
  
  <pre><code>import pandas 
  import seaborn
  import numpy as np
  dataFrameA = pd.DataFrame([ [1,2],[3,4] ])
  dataFrameB = pd.DataFrame( np.arange(3*6).reshape(3,-1))
  </code></pre>
  
  <p>Then decide how big the clustermap itself needs to be, something along the lines of:</p>
  
  <pre><code>dpi = 72
  cellSizePixels = 150
  </code></pre>
  
  <p>This decides that dataFrameA should be should be 300 by 300 pixels. I think that those need to be converted to the size units of the figure, which will be cellSizePixels/dpi units per pixel. So for dataFrameA that will be a heatmap size of ~2.01 inches. Here I am introducing a problem: there is stuff around the heatmap, which will also take up some space, and I don't know how much space those will exactly take. </p>
  
  <p>I tried to parametrize the heatmap function with a guess of the image size using the formula above:</p>
  
  <pre><code>def fixedWidthClusterMap( dpi, cellSizePixels, dataFrame):
      clustermapParams = {
          'square':False # Tried to set this to True before. Don't: the dendograms do not scale well with it.
      }
      figureWidth = (cellSizePixels/dpi)*dataFrame.shape[1]
      figureHeight= (cellSizePixels/dpi)*dataFrame.shape[0]
      return sns.clustermap( dataFrame, figsize=(figureWidth,figureHeight), **clustermapParams)
  
  fixedWidthClusterMap(dpi, cellSizePixels, dataFrameA)
  plt.show()
  fixedWidthClusterMap(dpi, cellSizePixels, dataFrameB)
  plt.show()
  </code></pre>
  
  <p>This yields:
  <a href="https://i.stack.imgur.com/5Zer2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Zer2.png" alt="Seaborn clustermap with bad scaling"></a></p>
  
  <p>My question: how do I obtain square cells which are exactly the size I want?</p>