Using ggplot(), I am trying to construct ANCOVA results in which the slopes of two linear components are equal: i.e. lm(y ~ x + A). The default behavior for geom_smooth(method = "lm")constructing separate slopes and intercepts for each level of each factor. For example, with two levelsA
library(ggplot2)
set.seed(1234)
n <- 20
x1 <- rnorm(n); x2 <- rnorm(n)
y1 <- 2 * x1 + rnorm(n)
y2 <- 3 * x2 + (2 + rnorm(n))
A <- as.factor(rep(c(1, 2), each = n))
df <- data.frame(x = c(x1, x2), y = c(y1, y2), A = A)
p <- ggplot(df, aes(x = x, y = y, color = A))
p + geom_point() + geom_smooth(method = "lm")

I can put ANCOVA separately with lm(), and then use geom_abline()to manually add lines. This approach has several drawbacks, for example, if the lines go beyond the data range and manually determine the colors.
fm <- lm(y ~ x + A, data = df)
summary(fm)
a1 <- coef(fm)[1]
b <- coef(fm)[2]
a2 <- a1 + coef(fm)[3]
p + geom_point() +
geom_abline(intercept = a1, slope = b) +
geom_abline(intercept = a2, slope = b)

I know that ancova()in the HH package it automates graphing, but I do not really like lattice graphics. Therefore, I am looking for a ggplot()centric solution.
library(HH)
ancova(y ~ x + A, data = df)
ggplot()? A , 3, 4 . formula geom_smooth(), , ( ).