Please note I am beginner with R. I have merged two data frames with one common column with merge() method. I have obtained data frame like:
x y1 y2
1 3
You should melt
your data into long format and then map the colour aesthetic to the variable column from the melted data.frame. Something like this:
dat <- data.frame(x = c(1,2,1,3), y1 = c(3,2,2,5), y2 = c(5,4,2,5))
dat.m <- melt(dat, id.vars = "x")
ggplot(dat.m, aes(x, value, colour = variable)) +
geom_point() +
scale_colour_manual(values = c("red", "blue"))
You can manually set the limits with xlim()
and ylim()
respectively. It's not clear what you're doing with alpha, so I'll leave that one up to you.