title: Matplotlib legend + tight_layout = squashed subplots
body: <p>Consider the following example:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from matplotlib import gridspec
  import numpy as np
  
  x = np.linspace(0, 10, 100)
  y = 2*x + 0.5
  
  plt.figure(figsize=(6, 4))
  gs = gridspec.GridSpec(2, 2)
  
  plt.subplot(gs[0, 0])
  plt.plot(x, y, "o")
  
  plt.subplot(gs[0, 1])
  plt.plot(x, y, "o")
  
  plt.subplot(gs[1, :])
  plt.plot(x, y, "o", label="test")
  plt.legend(loc="upper center", bbox_to_anchor=(0.5, 2.7))
  
  plt.subplot(gs[2, :])
  plt.plot(x, y, "o")
  
  plt.tight_layout()
  plt.show()
  </code></pre>
  
  <p>When I remove <code>bbox_to_anchor</code> from <code>plt.legend</code>, the above code should produce something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/aPN5k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aPN5k.png" alt="enter image description here"></a></p>
  
  <p>But when I place the legend outside of the subplot using <code>bbox_to_anchor</code> (as in the code above), the subplots get squashed:</p>
  
  <p><a href="https://i.stack.imgur.com/HhkUE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HhkUE.png" alt="enter image description here"></a></p>
  
  <p>Obviously, this is not desired. There seems to be a conflict between <code>bbox_to_anchor</code> and <code>tight_layout()</code> (if you remove either from the code above, something sensible comes out). Is there something I'm doing wrong, or is this known/expected behaviour?</p>
  
  <p>This problem is reproduced under various back-ends. I don't get any warnings or errors. I'm using matplotlib version <code>2.2.2</code>.</p>