title: Cannot unpack non-iterable AxesSubplot object- Matplotlib
body: <p>I am making a function in python which allows me to create two parallel graphs and they share their 2 axes:</p>
  <pre><code>def PlotManager(data1,data2,fig):
      f, (ax1, ax2) = fig.subplots(2, 1, sharey=True,sharex=True)
  
      #Plot1 sopra
      x_axis = data1.index
      #Plot and shade the area between the upperband and the lower band grey
      ax1.fill_between(x_axis,data1['Upper'],data1['Lower'], color = 'grey', alpha= 0.5)
      #Plot the closing price and the moving average
      ax1.plot(x_axis,data1['Close'],color = 'gold',lw = 3,label = 'Close Price', alpha= 0.5)
      ax1.plot(x_axis,data1['SMA'],color = 'blue',lw = 3,label = 'Simple Moving Average', alpha= 0.5)
      ax1.scatter(x_axis,data1['Buy'],color=&quot;green&quot;, lw=3,label=&quot;Buy&quot;,marker = &quot;^&quot;, alpha=1)
      ax1.scatter(x_axis,data1['Sell'],color=&quot;red&quot;, lw=3,label=&quot;Sell&quot;,marker = &quot;v&quot;, alpha = 1)
      #Set the title and show the image
      ax1.set_title(&quot;Bollinger Band for Amazon&quot;)
      plt.xticks(rotation = 45)
  
      #Plot 2 Sotto
      ax2.set_title('RSI_Plot')
      ax2.plot(x_axis,data2['RSI'])
      ax2.axhline(0,linestyle='--',alpha=0.5, color=&quot;grey&quot;)
      ax2.axhline(10,linestyle='--',alpha=0.5, color=&quot;orange&quot;)
      ax2.axhline(20,linestyle='--',alpha=0.5, color=&quot;green&quot;)
      ax2.axhline(30,linestyle='--',alpha=0.5, color=&quot;red&quot;)
      ax2.axhline(70,linestyle='--',alpha=0.5, color=&quot;red&quot;)
      ax2.axhline(80,linestyle='--',alpha=0.5, color=&quot;green&quot;)
      ax2.axhline(90,linestyle='--',alpha=0.5, color=&quot;orange&quot;)
      ax2.axhline(100,linestyle='--',alpha=0.5, color=&quot;grey&quot;)
  </code></pre>
  <p>But gives me  the <code>cannot unpack non-iterable AxesSubplot object</code> error:</p>
  <pre class="lang-none prettyprint-override"><code>[Command: python -u C:\Users\Nicolò\Documents\Git\ProgettoTradingBot\ProgettoTradeBot\GUIprova2.py]
  C:\Users\Nicolò\Documents\Git\ProgettoTradingBot\ProgettoTradeBot\BollingerBandsFinal.py:63: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
    ax = f.add_subplot(111)
  C:\Users\Nicolò\Documents\Git\ProgettoTradingBot\ProgettoTradeBot\BollingerBandsFinal.py:63: MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance.  In a future version, a new instance will always be created and returned.  Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
    ax = f.add_subplot(111)
  Traceback (most recent call last):
    File &quot;C:\Users\Nicolò\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\cbook\__init__.py&quot;, line 196, in process
      func(*args, **kwargs)
    File &quot;C:\Users\Nicolò\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\animation.py&quot;, line 951, in _start
      self._init_draw()
    File &quot;C:\Users\Nicolò\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\animation.py&quot;, line 1743, in _init_draw
      self._draw_frame(next(self.new_frame_seq()))
    File &quot;C:\Users\Nicolò\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\animation.py&quot;, line 1766, in _draw_frame
      self._drawn_artists = self._func(framedata, *self._args)
    File &quot;C:\Users\Nicolò\Documents\Git\ProgettoTradingBot\ProgettoTradeBot\GUIprova2.py&quot;, line 48, in animate
      PlotManager(BollingerBands(df,f),RSI(df,f2),f)
    File &quot;C:\Users\Nicolò\Documents\Git\ProgettoTradingBot\ProgettoTradeBot\mostraGrafici.py&quot;, line 7, in PlotManager
      f, (ax1, ax2) = fig.subplots(2, 1, sharey=True,sharex=True)
  TypeError: cannot unpack non-iterable AxesSubplot object
  </code></pre>
  <p>How can i handle to this error?</p>