plot_model()我正在尝试使用中的函数创建预测值图sjPlot。我希望我的预测线具有不同的线型和不同的颜色。
该函数包含一个colors参数,设置colors为bw将更改linetype,但设置colors为灰度。这个问题类似,但没有收到有用的答案:Coloredribsand differentlinetypesinsjPlotplot_model()
例子:
不同linetypes,但不是colors
data(iris)
toy_model <- lm( Sepal.Length ~ Sepal.Width + Species, data=iris)
my_plot <- plot_model(toy_model, type=("pred"),
terms=c("Sepal.Width","Species"),
colors="bw")
Run Code Online (Sandbox Code Playgroud)
不同colors,但不是linetypes
data(iris)
toy_model <- lm( Sepal.Length ~ Sepal.Width + Species, data=iris)
my_plot <- plot_model(toy_model, type=("pred"),
terms=c("Sepal.Width","Species"))
Run Code Online (Sandbox Code Playgroud)
怎样才能既不同colors又不同linetypes呢?换句话说,我想要这样的东西

stat_poly_eq我正在尝试使用的函数在绘图上显示方程ggpmisc。
我的问题是如何通过引用参数来改变方程中y= ...的。y1=...y2=...key
我尝试eq.with.lhs在映射中添加参数,但它无法识别该参数。我尝试将向量传递给eq.with.lhs参数,但它与每个方程中的两个元素重叠......
你有更好的主意吗?
在最后一种情况下,我可以geom_text自己计算方程系数后使用,但这似乎是解决问题的效率较低的方法。
这是我的问题的代表。
data <- data.frame(x = rnorm(20)) %>%
mutate(y1 = 1.2*x + rnorm(20, sd=0.2),
y2 = 0.9*x + rnorm(20, sd=0.3)) %>%
gather(value = value, key = key, -x)
ggplot(data, aes(x = x, y = value)) +
geom_point(aes(shape = key, colour = key)) +
stat_poly_eq(aes(label = ..eq.label.., colour = key),
formula = y ~ poly(x, 1, raw = TRUE),
eq.x.rhs = "x", …Run Code Online (Sandbox Code Playgroud)