I'd like to have two plots stacked up. What I did so far is I'm plotting live data this way:
def animate(i):
plt.tick_params(axis='y', which='both', labelleft=False, labelright=True)
plt.cla()
plt.plot(df.time, df.close)
plt.plot(df.time, df.sma)
plt.plot(df.time, df.price_line, 'g-')
plt.title('ETHUSDT')
ani = FuncAnimation(plt.gcf(), animate, interval = 200)
plt.tight_layout()
plt.pause(0.001)
Now I add a sublot this way:
vola_ax = plt.subplot(2,1,1)
vola_ax.plot(df.time, df.volatility)
But the when I run the code I get first this:

Then it turns to this:
But my desired output is (roughly)this:
How can I achieve this?


