I want to plot 3 regression lines, one for each value of tau, and each one with its colour, as specified in the dataset. The internet says you provide the color variable at the
ggplot 'maps' aesthetics to scales, meaning that it tries to fit a variable onto a scale. The default scale for categorical variables is scale_colour_discrete()
, which matches a colour to every unique entry. Since ggplot doesn't know that the values in your col
column are colour names, you have to let ggplot know that these colours are to be interpreted literally. You can do that with scale_colour_identity()
.
ggplot(ddl, aes(x = predictor, y = value, color = col)) +
geom_line(aes(group = tau),size = 0.8) +
scale_colour_identity()