英文:
How to make data points in ggPredict plot more transparent?
问题
这是我的代码:
fit4=lm(Response~r*delta*sw,data=ChemResearch4)
summary(fit4)
b<-ggPredict(fit4,colorn=10,add.data=FALSE)+
plot(b)+
labs(
x = "r",
y = "Response",
title = "Effect of delta and r on response, by sw values")
这是图表:
谢谢!
我尝试过使用geom_point,但一直出现错误。
英文:
this is my code:
fit4=lm(Response~r*delta*sw,data=ChemResearch4)
summary(fit4)
b<-ggPredict(fit4,colorn=10,add.data=FALSE)+
plot(b)+
labs(
x = "r",
y = "Response",
title = "Effect of delta and r on response, by sw values")
This is the plot:
Thank you!
I tried geom_point, but it constantly shows error.
答案1
得分: 0
我看不到在 ggPredict
函数内部更改透明度的选项,但由于它生成了一个 ggplot 对象,您可以在绘制完成后将透明度作为美学参数添加到点图层中。
由于我们没有您的数据,所以这里是一个使用内置的 mtcars
数据集的完整 reprex:
library(ggiraphExtra)
fit4 <- lm(mpg ~ wt * hp, data = mtcars)
b <- ggPredict(fit4, colorn = 10, add.data = FALSE)
plot(b)
请注意,点是完全不透明的。要使它们半透明,我们可以执行以下操作:
b$layers[[1]]$aes_params <- list(alpha = 0.2)
plot(b)
创建于2023年07月13日,使用 reprex v2.0.2
英文:
I don't see an option to change the transparency within the ggPredict
function itself, but since it produces a ggplot object, you can add transparency as an aesthetic parameter to the point layer after the plot is produced.
We don't have your data, so here is a full reprex using the built-in mtcars
data set:
library(ggiraphExtra)
fit4 <- lm(mpg ~ wt * hp, data = mtcars)
b <- ggPredict(fit4, colorn = 10, add.data = FALSE)
plot(b)
Note the points are fully opaque. To make them transparent, we can do:
b$layers[[1]]$aes_params <- list(alpha = 0.2)
plot(b)
<sup>Created on 2023-07-13 with reprex v2.0.2</sup>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论