As I understand correctly, the file "datagrid.txt"
contains something like
1 2 3
4 5 6
7 9 0
. . .
. . .
. . .
If so, then loadtxt
loads it as two-dimensional array. Hence, you need to change the line setting x
, t
, and u
into:
x, t, u = datalist[:,0], datalist[:,1], datalist[:,2]
or even simpler and more Pythonic:
x, t, u = datalist.transpose()
or as the third option, read your file as:
x, t, u = loadtxt("datagrid.txt", unpack=True)