title: Subplots mess with my plot
body: <p>I have the following plot function that saves a random walk input <em>(the random walk is supposed to mimic a stock and bond portfolio that rebalances between each other given specific inputs, the exposure is supposed to show the exposure to the stock portfolio)</em>:  </p>
  
  <pre><code>def stock_save_img_run(k):
      stock_vals = pd.read_csv('stock_vals_run_' + str(k) + '.csv', sep=';', encoding='utf-8-sig')
      plt.subplot(2, 1, 1)
      plt.plot(stock_vals['date'], stock_vals['stock_val'], color='#191970')
      plt.plot(stock_vals['date'], stock_vals['protected_amt'], color='#191970', ls='dashed')
      plt.stackplot(stock_vals['date'], stock_vals['exposure'] * stock_vals['stock_val'], (1 - stock_vals['exposure']) * stock_vals['stock_val'], color=('gray'), colors=('gray', 'silver'))
      plt.subplot(2, 1, 2)
      plt.plot(stock_vals['date'], stock_vals['exposure'], color='#191970', lw='0.5')
      plt.ylabel('Exposure (in %)')
      plt.savefig('chart_' + str(k) + '.png')
      plt.show()
      plt.cla()
      del stock_vals
  </code></pre>
  
  <p>The regular output should look like this:
  <a href="https://i.stack.imgur.com/iujgx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iujgx.png" alt="correct output"></a></p>
  
  <p>This works for the first run. If I run the script again, the output will look like this:
  <a href="https://i.stack.imgur.com/F6CNx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F6CNx.png" alt="incorrect output"></a></p>
  
  <p>In order to get the plot to look normal again, I have to uncomment this line:<br>
  <code>##plt.plot(stock_vals['date'], stock_vals['exposure'], color='#191970', lw='0.5')</code></p>
  
  <p>As you can imagine, the output will look like this for this particular run:
  <a href="https://i.stack.imgur.com/tp5OL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tp5OL.png" alt="third run to reset"></a></p>
  
  <p>As you can see, the chart on the top looks normal again. When I run it again (fourth run), both charts will look like they are supposed to look. The fifth run will destroy everything again - rinse and repeat.</p>
  
  <p>Given that I know the workaround to get it solved, I'm flabbergasted as to why this occurs.</p>