The application I'm coding for requires a real time plot of incoming data that is being stored long term in an excel spreadsheet. So the real time graph displays the 25 most recent data points.
The problem comes when the plot has to shift in the newest data point and shift out the oldest point. When I do this, the graph "smears" as shown here:

I then began to use plt.cla(), but this causes me to lose all formatting in my plots, such as the title, axes, etc. Is there any way for me to update my graph, but keep my graph formatting?
Here's an example after plt.cla():
.
And here's basically how I'm updating my graphs within a larger loop:
if data_point_index < max_data_points:
y_data[data_point_index] = measurement
plt.plot(x_data[:data_point_index + 1], y_data[:data_point_index + 1], 'or--')
else:
plt.cla()
y_data[0:max_data_points - 1] = y_data[1:max_data_points]
y_data[max_data_points - 1] = measurement
plt.plot(x_data, y_data, 'or--')
plt.pause(0.00001)
I know I can just re-add axis labels and such, but I feel like there should be a more eloquent way to do so and it is somewhat of a hassle as there can be multiple sub-plots and reformatting the figure takes a non-trivial amount of time.