使用 Sjplot 绘图时可以根据组更改数据点的形状吗?

Can the shape of data points be changed according to group when plotting with Sjplot?

我正在尝试优化黑白打印的 sjPlot。

我的情节主要看寄生虫的数量,这取决于降雨量,并按繁殖状况分类。

我的数据分为单身汉组和 breeder/territorial 男性组。

虽然在 plot.model 函数中对颜色使用 "bw" 时,我可以将预测线(GLMM pred 模型)分解为虚线和实线,但我无法更改形状(甚至灰度颜色)的原始数据点的两组。

当使用不同的配色方案时,我可以按组拆分数据点的颜色,但这种区别在 "bw" 时消失了(所有点都是相同的阴影)。

要点: 有没有办法在两条预测线之间保持虚线和实线的区别(使用 [colors="bw"] 实现)并改变形状或sjPlot 中按组划分的原始数据点的颜色?提前致谢!

我尝试过使用各种添加物来改变形状;但是,没有任何效果。以下是我尝试过的情节中的一些代码添加:

aes(shape=Reproductive_Status)

dot.shape="Reproductive_Status"

group="Reproductive_Status"....shape=group

代码:GlmmTMB模型的设置

strong.2.int.y<-glmmTMB(log.strongyle. 
 ~ Rainfall_2MDelay*Reproductive_Status+age_y+(
   1 | Animal_ID),data=parasites,na.action=na.exclude)

代码:情节;不幸的是,"aes(shape=Reproductive_Status)" 在这个函数中没有改变点的形状

test2.plot_strong.2.int.y.bw<-plot_model(strong.2.int.y, type ="pred", terms = c("Rainfall_2MDelay","Reproductive_Status"), 
  sort.est = NULL, rm.terms = NULL, group.terms = NULL, pred.type = "fe", 
  title = "(a)", axis.title = NULL, axis.labels = NULL, legend.title = NULL, 
  colors = "bw", show.intercept = FALSE, show.values = TRUE, show.p = F, 
  show.data = T, show.legend = TRUE, digits = 2, show.scatter=T, 
  dot.size = 2, dot.alpha=0.3,line.size = 1, vline.color = NULL, 
  aes(shape=Reproductive_Status)) 
  + labs(x=expression('Rainfall, R'[t-2]*' (mm)'), 
     y="Strongyle Count (log[x])") 
     + theme(plot.title = element_text(hjust=0.0))


plot(test2.plot_strong.2.int.y.bw,add=TRUE)

对于边际效应图(即当 type = "pred" 时),sjPlot 只是调用 ggeffects. So if you're familiar with ggplot2, I suggest you use directly ggpredict() 中的函数,returns 是绘图所需的基础数据。

你也可以试试ggeffects'plot()-method,然后尝试自定义。有两个小插图描述了如何自定义绘图: Plotting Marginal Effects and Customize Plot Appearance.

希望对您有所帮助。