title: Seaborn set figsize=(x,y) error and warning about tight_layout "tight_layout cannot make axes height small enough to accommodate all axes decorations"
body: <p>I have a 10-plot FacetGrid chart in Seaborn with slightly overlapping plots. I want to change the size of the overall figure.  When I use g.fig.subplots(figsize=(12,12)) in the code below, I get an error message <code>TypeError: subplots() got an unexpected keyword argument 'size'</code>.  </p>
  
  <p>Also, I get a warning about <code>UserWarning: Tight layout not applied. tight_layout cannot make axes height small enough to accommodate all axes decorations self.fig.tight_layout()</code></p>
  
  <p>I don't see anywhere in my code where tight_layout() is referenced.  It is embedded in the module: <code>C:\Anaconda3\lib\site-packages\seaborn\axisgrid.py:848</code>.  I don't want to muck around in a site packages module.  How do I adjust parameters so that I don't get this warning.    </p>
  
  <p>I want to fix the problem, not just suppress this warning.  I don't know enough about the internals of Seaborn and Matplotlib to fix this error and get rid of the warning.  </p>
  
  <p>I tried adding <code>g.fig.subplots(figsize=(12,12))</code> to change the figure size.  Apparently FacetGrid plots are not contained in a figure, or I am referencing the figure bounding box object incorrectly.  </p>
  
  <pre><code>"""
  FacetGrid Plot Showing Overlapping Distributions (Densities) Offset by ('ridge plot')
  ====================================
  """
  import numpy as np
  import pandas as pd
  import seaborn as sns
  import matplotlib.pyplot as plt
  sns.set(style="white", rc={"axes.facecolor": (0, 0, 0, 0)})
  
  # Create some random distribution data and labels, and store them in a dataframe
  rs = np.random.RandomState(1979)
  x = rs.randn(500)
  g = np.tile(list("ABCDEFGHIJ"), 50)
  df = pd.DataFrame(dict(x=x, g=g))
  m = df.g.map(ord)
  df["x"] += m
  
  # Initialize the FacetGrid chart object
  pal = sns.cubehelix_palette(10, rot=-.25, light=.7)
  g = sns.FacetGrid(df, row="g", hue="g", aspect=15, height=.5, palette=pal)
  
  # Draw the densities in a few steps
  g.map(sns.kdeplot, "x", clip_on=False, shade=True, alpha=1, lw=1.5, bw=.2)
  g.map(sns.kdeplot, "x", clip_on=False, color="w", lw=2, bw=.2)
  g.map(plt.axhline, y=0, lw=2, clip_on=False)
  
  
  # Define and use a simple function to label the plot in axes coordinates
  def label(x, color, label):
      ax = plt.gca()
      ax.text(0, .2, label, fontweight="bold", color=color,
              ha="left", va="center", transform=ax.transAxes)
  
  # Use ``map()`` to calculate the label positions
  g.map(label, "x")
  
  # Set the subplots to overlap slightly on their vertical direction
  g.fig.subplots_adjust(hspace=-.3)
  
  # Remove axes details that don't play well with overlap
  g.set_titles("")
  g.set(yticks=[])
  g.despine(bottom=True, left=True)
  g.fig.subplots(figsize=(12,12))  # Don't know how to change figure size for a set of overlapping Seaborn plots
  </code></pre>
  
  <p>I get the following warning, followed by the error message after that, and then the FacetedGrid plot is displayed without changing its size.   </p>
  
  <pre><code>  self.fig.tight_layout()
  C:\Anaconda3\lib\site-packages\seaborn\axisgrid.py:848: UserWarning: Tight layout not applied. tight_layout cannot make axes height small enough to accommodate all axes decorations
    self.fig.tight_layout()
  C:\Anaconda3\lib\site-packages\seaborn\axisgrid.py:848: UserWarning: Tight layout not applied. tight_layout cannot make axes height small enough to accommodate all axes decorations
    self.fig.tight_layout()
  </code></pre>
  
  <hr>
  
  <pre><code>&lt;ipython-input-25-a661dbef6e83&gt; in &lt;module&gt;
       43 g.set(yticks=[])
       44 g.despine(bottom=True, left=True)
  ---&gt; 45 g.fig.subplots(size=(12,12))  # Don't know how to change figure size for a set of overlapping Seaborn plots
  
  TypeError: subplots() got an unexpected keyword argument 'size'
  
  </code></pre>
  
  #############
  
  <p>After all comments were integrated, here's the source code for a good, tight plot without warnings or errors:</p>
  
  <pre><code>`# -*- coding: utf-8 -*-
  """ Created on Mon Jun 24 12:21:40 2019 @author: rlysak01 
  FacetGrid Plot Showing Overlapping Distributions (Densities) Offset by ('ridge plot')
  """
  import numpy as np
  import pandas as pd
  import seaborn as sns
  import matplotlib.pyplot as plt
  sns.set(style="white", rc={"axes.facecolor": (0, 0, 0, 0)})
  
  # Create some random distribution data and labels, and store them in a dataframe
  rs = np.random.RandomState(1979)
  x = rs.randn(500)
  g = np.tile(list("ABCDEFGHIJ"), 50)
  df = pd.DataFrame(dict(x=x, g=g))
  m = df.g.map(ord)
  df["x"] += m
  
  # Initialize the FacetGrid chart object
  pal = sns.cubehelix_palette(10, rot=-.25, light=.7)
  # g = sns.FacetGrid(df, row="g", hue="g", aspect=6, height=1.0, palette=pal)
  g = sns.FacetGrid(df, row="g", hue="g", palette=pal)
  
  ''' Alternatively set figsize using the following 2 parameters.'''
  g.fig.set_figheight(5.5)
  g.fig.set_figwidth(7)
  # or use plt.gcf().set_size_inches(12, 12)
  
  # Draw the densities in a few steps
  g.map(sns.kdeplot, "x", clip_on=False, shade=True, alpha=1, lw=1.5, bw=.2)
  g.map(sns.kdeplot, "x", clip_on=False, color="w", lw=2, bw=.2)
  g.map(plt.axhline, y=0, lw=2, clip_on=False)
  
  # Define and use a simple function to label the plot in axes coordinates
  # Values x,y in ax.text(x,y, ...) controls the x,y offset from the x axis.
  def label(x, color, label):
      ax = plt.gca()
      ax.text(0, .2, label, fontweight="bold", color=color,
              ha="left", va="center", transform=ax.transAxes)
  
  # Use ``map()`` to calculate the label positions
  g.map(label, "x")
  
  # Set the subplots to overlap slightly on their vertical direction
  g.fig.subplots_adjust(hspace=-0.5)
  
  # Remove axes details that don't play well with overlap
  g.set_titles("")
  g.set(yticks=[])
  g.despine(bottom=True, left=True)
  `
  </code></pre>