def matplotlib(i):
graph_data = open('sampleData.txt', 'r').read()
lines = graph_data.split('\n')
xs = []
ys = []
for line in lines:
if len(line) >1:
x, y = line.split(',')
xs.append(x)
ys.append(y)
fig.clear()
'Limits'
ax = plt.gca()
ax.set_xlim([80, -80])
ax.set_ylim([42, -42])
plt.axis('equal')
'Labels'
plt.xticks([-16, -32, -48, -64, -80, 0, 16, 32, 48, 64, 80])
plt.yticks([-42, -28, -14, 0, 14, 28, 42])
plt.show()
plt.scatter(xs, ys)
'Toolbar Buttons'
insertButt = Button(toolbar, text="Matplotlib TST", fg='Dark Red', bg="Dim Grey", activebackground='Dim Grey',
activeforeground='Dark Red', command=matplotlib).pack(side=LEFT, padx=2, pady=2)
ani = animation.FuncAnimation(fig, matplotlib, interval=1000)
The problem occurs when I try to run the function using a button. It works fine without the use of a button. I get the error,
matplotlib() missing 1 required positional argument: 'i'
I tried to fix this by simply removing the, i, then I got the error,
matplotlib() takes 0 positional arguments but 1 was given
I also tried putting (i) after command=matplotlib(i) in my button, my graph turned blank, and then I got this error,
matplotlib() takes 0 positional arguments but 1 was given
I am just trying to find to find out how to make a live graph, what the, i, even means, and I'm not sure why it doesn't work only when I run it with a button in Tkinter.