title: Python & Matplotlib: creating two subplots with different sizes
body: <p>I have a script which is creating one or two charts, depending on if one specific condition is met or not. Really basically, what I am doing so far is the following: </p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  list1 = [1,2,3,4]
  list2 = [4,3,2,1]
  somecondition = True
  plt.figure(1) #create one of the figures that must appear with the chart
  ax = plt.subplot(211) #create the first subplot that will ALWAYS be there
  ax.plot(list1) #populate the "main" subplot
  if somecondition == True:
     ax = plt.subplot(212) #create the second subplot, that MIGHT be there
     ax.plot(list2) #populate the second subplot
  plt.show()
  </code></pre>
  
  <p>This code (with the proper data, but this simple version that I did is executable anyway) generates two subplots of the same size, one above the other. However, what I would like to get is the following: </p>
  
  <ul>
  <li>If somecondition is <strong>True</strong>, then both subplots should appear in the figure. Hence, I would like the second subplot to be 1/2 smaller than the first one; </li>
  <li>If somecondition is <strong>False</strong>, then just the first subplot should appear and I would like it to be sized as the all figure (without leaving the empty space behind in the case the second subplot will not appear). </li>
  </ul>
  
  <p>I'm pretty sure it's just a matter of sizing the two subplots, probably even by the parameter 211 and 212 (that I don't understand what they stand for, since I'm new to Python and couldn't find a clear explanation on the web yet). Does anyone know how to regulate the size of the subplots in a easy way, proportionally to the number of subplots as well as to the entire size of the figure? To make it easier to understand, could you also please edit my simple code I attached to get the result I'm looking for? Thanks in advance! </p>