为什么我可以在我的cat_plot中使用col =添加颜色?

发布于 2025-01-31 03:43:36 字数 483 浏览 1 评论 0原文

“图1”

我正在尝试用我的cat_plot color blue制作线条。我尝试了以下代码,将col =靠近GEOM = C(“ line”)旁边:

library(interactions) 
Figure01 <- cat_plot(M1, pred = "OA_status", geom = c("line", col = "blue"), interval = TRUE, 
        x.label = 'OA Status', y.label = 'Predicted Altmetric Score', 
        main.title = 'Figure 1')
Figure01

但是我只得到附加的图片。如您所见,该图中的线并不蓝色。我要在哪里出错 - col =在错误的地方?还是颜色参数不适用于这种类型的图?

Figure 1

I am trying to make the lines in my cat_plot color blue. I have tried the following code, putting the col = next to the geom = c("line"):

library(interactions) 
Figure01 <- cat_plot(M1, pred = "OA_status", geom = c("line", col = "blue"), interval = TRUE, 
        x.label = 'OA Status', y.label = 'Predicted Altmetric Score', 
        main.title = 'Figure 1')
Figure01

But I am only getting the attached picture. As you can see, the lines are not blue in this plot. Where am I going wrong— is the col = in the wrong place? Or is the color argument not applicable for this type of plot?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘紸啶 2025-02-07 03:43:36

我将钻石数据集用作示例。您需要使用颜色而不是col。您可以做的是取决于因素的数量,例如这样的图:

library(interactions)
library(ggplot2)
fit <- lm(price ~ cut * color, data = diamonds)
cat_plot(fit, pred = color, modx = cut, interval = TRUE, geom = "line", colors = c(rep("blue", 5)))

outupt:

“在此处输入图像说明”

I am using the diamonds dataset as an example. You need to use colors instead of col. What you can do is depending on the number of factors is adding blue to your plot like this:

library(interactions)
library(ggplot2)
fit <- lm(price ~ cut * color, data = diamonds)
cat_plot(fit, pred = color, modx = cut, interval = TRUE, geom = "line", colors = c(rep("blue", 5)))

Output:

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文