You have to filter your data as well, because I assume that you don't want a single alternating colored line but two separated and separately colored lines.
I modified your test data because the original would be a bit unfortunate for illustration.
For using lc var
you have to provide a number which you can do e.g. via defining a function myColor()
.
Code:
### filtering data and apply color
reset session
$sample <<EOD
2020-02-01 1 Foo
2020-02-01 7 Bar
2020-03-01 5 Foo
2020-03-01 9 Bar
2020-04-01 10 Foo
2020-04-01 20 Bar
EOD
set key top left
myTimeFmt = "%Y-%m-%d"
set format x "%Y\n%m\n%d" timedate
myFilter(dcol,fcol,key) = strcol(fcol) eq key ? column(dcol) : NaN
set datafile missing NaN
myColor(col) = strcol(col) eq "Foo" ? 0xff0000 : strcol(col) eq "Bar" ? 0x0000ff : 0x000000
keys = "Foo Bar"
plot for [key in keys] $sample u (timecolumn(1,myTimeFmt)):(myFilter(2,3,key)):\
(myColor(3)) w lp pt 7 lc rgb var title key
### end of code
Result:

Addition: (you can mimic a hash or lookup table)
keys = "Foo Bar Xyz"
myColorList = "0xff0000 0x0000ff 0x000000"
myColor(s) = (tmp=NaN, sum [i=1:words(keys)] (word(keys,i) eq s ? (tmp=word(myColorList,i),0) : 0), int(tmp))
plot for [key in keys] $sample u (timecolumn(1,myTimeFmt)):(myFilter(2,3,key)):\
(myColor(key)) w lp pt 7 lc rgb var title key
Example:
print myColor("Foo") # result will be 16711680 which is 0xff0000 in hex