Is this what you want?
ggplot(data = df) +
geom_line(aes(time, x, color = "X")) +
geom_line(aes(time, y, color = "Y")) +
geom_line(aes(time, z, color = "Z")) +
xlab("Time") +
ylab("value") +
labs(color = "YOUR LEGEND TITLE")

although @akrun is right, converting your data to long format would be the way to go here:
library(reshape2)
df <- melt(df, id.vars = "time")
> df
time variable value
1 1 x 1
2 2 x 2
3 3 x 3
4 4 x 4
5 1 y 2
6 2 y 4
7 3 y 6
8 4 y 8
9 1 z 1
10 2 z 3
11 3 z 5
12 4 z 7
and then
ggplot(data = df, aes(x = time, y = value, color = variable)) +
geom_line() +
xlab("Time") +
ylab("value") +
labs(color = "YOUR LEGEND TITLE")
The legend-title is optional btw:
ggplot(data = df, aes(x = time, y = value, color = variable)) +
geom_line() +
xlab("Time") +
ylab("value") +
labs(color = "")
library(tidyverse);df %>% gather(key, val, -time) %>% ggplot(aes(x = time, y = val, color = key)) + geom_line()geom_labelfor the labelgeom_label(label=colnames(df[,-1]), but no change to the existing plot. Thanks for the suggestions~!