I have a dataset that receives manual input that adds rows one-by-one. I want to create a scatterplot to plot the data and update when more data is added. Using matplotlib, how would I go about updating the existing plot, instead of redrawing the entire thing? I have the plot all laid out, it's just adding the points. So here's what I have so far:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame([[1, 3.00]], columns=['At_Bat', 'Stand'])
plt.ion()
x = np.arange(0, 999, 0.1)
y1 = -5
y2 = .75
y3 = 2.25
y4 = 5
plt.fill_between(x, y1, y2, color='lawngreen', alpha='.6')
plt.fill_between(x, y2, y3, color='yellow', alpha='.6')
plt.fill_between(x, y3, y4, color='red', alpha='.6')
plt.scatter(df.At_Bat, df.Stand)
plt.plot(df.At_Bat, df.Stand)
plt.axhline(y=0, color='black')
plt.xticks(np.arange(0, df.Stand.max() + 1))
plt.ylim([-4, 4])
plt.xlim([0, df.Stand.max() + 1])
df2 = pd.DataFrame([[2, 2.50]])
df = np.append(df, df2, axis = 0)
So df contains the first point, and then each additional point is added using df2 and append.