I have two dataframes, each having one hundred 'x' and 'y' coordinates I wish to plot together on a single line plot. I can get the lines to plot, but am running into trouble trying to colour the lines and add a legend to the graph.
From my understanding it might be better to combine the two dataframes into one and add a column with the two series names, but for now it's best if the two are separate. I can replicate the problem using the mtcars datasets.
library(ggplot2)
library(dplyr)
df <- mtcars
df1 <- select(df, wt, qsec)
df2 <- select(df, wt, disp)
ggplot() +
geom_line(data = df1, aes(x = wt, y = qsec, colour = "blue")) +
geom_line(data = df2, aes(x = wt, y = disp, colour = "red"))
I get the following plot using the code; below that is the original problem with my data.
I have tried to use the scale_color functions below on my data with no success
scale_color_manual(values = c("Offset"="blue", "Initial"="red"))
scale_color_discrete(name="Geometry", labels = c("Initial", "Offset"))
Colin