Hi, I am trying to plot live data reading them from a txt file. The interesting thing is that it works fine without the animate function and I am not sure what is going on when I introduce this function. The code is appended below.

from datetime import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.animation as animation
from matplotlib import style

fig = plt.figure()
ax1 = fig.add_subplot(1,1,1, axisbg = 'white')
#rect = fig.patch

def animate(i):
    readFile = open ('CoolTerm Capture 2016-06-03 00-36-52.txt', 'r')
    sepFile = readFile.read().split('\n')
    for idx, plotPair in enumerate(sepFile):
        if idx > 1:
            xAndY = plotPair.split(',')
            time_string = xAndY[0]
            time_value = datetime.strptime(time_string, '%Y-%m-%d %H:%M:%S')
            print time_string
            ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))
            ax1.plot(xs, ys)
            plt.title("PT100 temperature sensor")
            ani = animation.FuncAnimation(fig, animate, interval = 1000)

What error message(s) are you getting?

It looks to me this,print time_string, could be a problem.
Try print (time_string).

Thank you, but I have solved the problem. Thanks much!

Please remember to mark this solved. Thanks