Jan-04-2020, 08:30 PM
I am trying to use a matplotlib module in order to draw data coming from notepad the problem is that I must clear the data every time I parse data in order to plot the data by using plt.clear() now I want to have other alternatives as when I want to zoom in for the graph it returns automatically to the previous plotting which is annoying. The following is considered as a sample of the code
f = Figure(figsize=(5,5), dpi=100) a = f.add_subplot(111) def animate(i): pullData = open("sampleText.txt","r").read() dataList = pullData.split('\n') xList = [] yList = [] line,=plt.plot([],[]) for eachLine in dataList: if len(eachLine) > 1: x, y = eachLine.split(',') xList.append(int(x)) yList.append(int(y)) line.set_data(xList,yList) a.clear()##the part that I want to have an alternative code for it a.plot(xList, yList)Thanks for any help