I have finished the code so far that I have created a list that stores all textdatein and then iterates over them. However, it currently overwrites all previous text files and only plots the last one. What is missing in my code that all previous text files are saved and plotted and the last one too?
def openFile(self):
filelist = []
for i in range(2):
files = filedialog.askopenfilename()
filelist.append(files)
for fname in filelist:
with open(fname) as f:
lines = f.readlines()
x = [float(line.split(",")[0]) for line in lines]
y = [float(line.split(",")[1]) for line in lines]
self.plot4.set_data(x,y)
self.ax4.set_xlim(min(x),max(x))
self.ax4.set_ylim(min(y),max(y))
self.canvas.draw_idle()
self.canvas.is_saving()

.set_data(x,y)because it replaces previous values in plot. You should useplot(x,y)every data. OR maybe evenplot(x1, y1, x2, y2, ...)But both versions will plot all on one grid. If you need separated plots then you will need alsosubplots()Cancelin dialogaskopenfilenamethenfileswill beNoneand you should check this before you add tofilelist