title: Can you copy only some subplots to a new figure?
body: <p><strong>Is there a way to copy an axis (subplot) to a new figure?</strong>
  This is straightforward in other languages, but I understand that not even a deep copy would work with python's matplotlib.
  E.g. if I have a figure with 6 subplots, how can I copy 2 of those subplots to a new figure, with all the settings? Labels, tickmarks, legend, grid, etc.</p>
  
  <p>I have found this <a href="https://stackoverflow.com/a/45812071/4045275">answer</a> , which is actually 2 in 1: the first no longer works (deprecated syntax), while I couldn't get the second to work in my case.</p>
  
  <p>I manage to recreate a new figure and to remove the subplots I don't want, but I am left with a 3x2 grid of subplots, in which 2 are drawn and 4 are empty. <strong>Any suggestions?</strong></p>
  
  <p>I have put together a toy example below; my charts are, of course, way more complex with way more settings.</p>
  
  <p>Note I used seaborn but it should be irrelevant - I believe this is a matplotlib question and the answer is going to be the same regardless of whether seaborn is used.</p>
  
  <p><strong>UPDATE</strong>: Following the tips from @Earnest, I can change the geometry of the new figure so that it only has two subplots, doing:</p>
  
  <pre><code>axes.change_geometry(1,2,2)
  </code></pre>
  
  <p>What I don't know how to do is to move the subplots around. To recap:</p>
  
  <ul>
  <li>I start with 6 subplots in a 3x2 grid.</li>
  <li>I pickle to memory, then unpickle to a new figure.</li>
  <li>In the new figure, I keep only subplots 1 and 2, i.e. those identified by [rows, columns] [0,1] and [1,0]; the other 4 subplots are now blank spaces.</li>
  <li>I want a [1x2] grid layout; if I do <code>axes.change_geometry(1,2,2)</code> then I get that layout, but one of my two subplots disappears.</li>
  </ul>
  
  <p>Any suggestions?</p>
  
  <pre><code>    import numpy as np
      import matplotlib.pyplot as plt
      import matplotlib
      import seaborn as sns
      import pickle
      import io
  
  
      sns.set(style='darkgrid')
  
      n=int(100)
      x=np.arange(0,n)
  
      fig, ax = plt.subplots(3,2)
  
      for i,a in enumerate(ax.flatten() ):
          y= np.random.rand(n)
          sns.lineplot( x, y , ax =a )
          a.set_title('Chart # ' + str(i+1))
          a.set_xlabel('my x')
          a.set_ylabel('my y')
  
      fig2, ax2 = plt.subplots(1,2)
  
      buf = io.BytesIO()
      pickle.dump(fig, buf)
      buf.seek(0)
  
      fig2=pickle.load(buf)
  
      tokeep=[1,2]
  
      # note that i == 1correponds to a[0,1]
      for i,a in enumerate(fig2.axes):
          if not i in(tokeep):
              fig2.delaxes(a)
          else:
              axes=a
  </code></pre>