ggplot2
is my favourite R package, so here is how I would solve this:
df = data.frame(difficulty = 2 + (runif(200) * 6),
ID = rep(c("point", "bubble"), each = 100))
df$movement = rep(c(1.2, 1.4), each = 100) * df$difficulty + (runif(200) / 5)
library(ggplot2)
theme_set(theme_bw())
ggplot(df, aes(x = difficulty, y = movement, color = ID, shape = ID)) +
geom_point() +
stat_smooth(method = 'lm')
1
solved Plotting two scatter plots and regression lines with error bars on same plot using ggplot2 [closed]