The variable i in [i in columns] is actually a string. So, convert it to an integer via int(i).
If you want to plot a column defined by an integer variable, use ... using (column(i))....
So, in combination:
Code:
### plot column numbers from a sequence in a string
reset session
set key top left
$Data <<EOD
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45
51 52 53 54 55
EOD
columns="2 3 5 1 4"
plot for [i in columns] $Data using 1:(column(int(i))) w lp title sprintf("Column %s",i)
### end of code
In your case remove the datablock $Data <<EOD ... EOD and in the plot command replace $Data with "mydata.dat"
Result:
