title: How to rearrange subplots so that one is underneath the other?
body: <p>I am trying to code two plots such that one plot is underneath the other. However, my code keeps aligning my two plots next to one another. 
  This is my code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import numpy as np
  from scipy.integrate import odeint
  from numpy import sin, cos, pi, array
  import matplotlib
  from matplotlib import rcParams
  import matplotlib.pyplot as plt
  from pylab import figure, axes, title, show
  import xlsxwriter
  
  plt.style.use('ggplot')
  
  def deriv(z, t):
      l = 0.25    #unextended length of the spring, in m
      m = 0.25       #mass of the bob, in kg
      k = 29.43      #spring constant, in Nm^-1
      g = 9.81    #gravitational acceleration, in ms^-2
      
      x, y, dxdt, dydt = z
      
      dx2dt2 = (l+x)*(dydt)**2 - k/m*x + g*cos(y)
      dy2dt2 = (-g*sin(y) - 2*(dxdt)*(dydt))/(l+x)
              #equations of motion
      
      return np.array([dxdt, dydt, dx2dt2, dy2dt2])
  
  
  init = array([0, pi/2, 0, 0])
              #initial conditions (x, y, xdot, ydot)
  
  time = np.linspace(0, 10, 1000)
              #time intervals (start, end, number of intervals)
  
  sol = odeint(deriv, init, time)
              #solving the equations of motion
  
  x = sol[:,0]
  y = sol[:,1]
  
  fig, (ax1, ax2) = plt.subplots(1, 2, sharex=True)
  
  ax1.plot(time,x)
  ax1.set_ylabel('hi')
  
  ax2.plot(time,y)
  ax2.set_ylabel('fds')
  
  plt.plot()</code></pre>
  </div>
  </div>
  </p>
  
  <p>but I keep getting this as a result:
  <a href="https://i.stack.imgur.com/tMDVY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tMDVY.png" alt="enter image description here"></a></p>
  
  <p>I have tried:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>plt.subplot(x)
  plt.subplot(y)
  plt.show()</code></pre>
  </div>
  </div>
  </p>
  
  <p>but I run into this error:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Traceback (most recent call last):
    File "/Users/cnoxon/Desktop/Python/Final code 2 copy 2.py", line 39, in &lt;module&gt;
      plt.subplot(x)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/pyplot.py", line 1084, in subplot
      a = fig.add_subplot(*args, **kwargs)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/figure.py", line 1367, in add_subplot
      a = subplot_class_factory(projection_class)(self, *args, **kwargs)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/matplotlib/axes/_subplots.py", line 39, in __init__
      s = str(int(args[0]))
  TypeError: only size-1 arrays can be converted to Python scalars
  &gt;&gt;&gt; </code></pre>
  </div>
  </div>
  </p>
  
  <p>How should I go about solving either of these problems? Alternative solutions are equally appreciated - I have no preference as to how the plots are created; I just want one to be under the other. Thank you!</p>