首页 > 解决方案 > ggplot2 用于交互图 APA 风格

问题描述

我正在为 APA pub 创建一个交互图。我很接近,但有些事情我无法弄清楚:

  1. 如何让两条交互线仅显示从 -1 SD 到 +1 SD?
  2. 如何添加点形状,以便每个主持人级别都有一个代表 -1SD 和 +1 SD 点的正方形或三角形
  3. 有没有办法改变 x 轴,使其不显示刻度线,而是将“低代理”和“高代理”标签与 -1 SD 和 +1 SD 点对齐?

我的代码:

model.interactions.4 <- lm(posemo.t1.t2 ~ (agency.cent * investor_count.cent) +
                           agency.cent + investor_count.cent +
                           communion.cent +
                           gender_d.cent + first_time_founder_d.cent +
                           num_years_in_business.cent + statuses_count.cent, 
                        data = h_vars)

p <- interactions::interact_plot(model.interactions.4,
                            pred = agency,
                            modx = investor_count,
                            modx.values = "plus-minus",
                            x.label = "Agency",
                            y.label = "Change in Positive Affect, t1 to t2",
                            modx.labels = c("Low Investor Count", "High Investor Count"))
p + jtools::theme_apa()

具有所需更改的当前图表:

在此处输入图像描述

编辑:理想情况下,我试图让图表模仿这种美学(这来自 APA 交互图的 Excel 模板): 在此处输入图像描述

编辑:前 10 行数据的表示:

structure(list(posemo.t1.t2 = c(-1.68, -2.3, -1.58, -2.12, 0.22, 
1.06, 0.0600000000000005, -2.54, -0.92, -1.99), agency.cent = c(0.0649148418491476, 
0.514914841849148, -0.195085158150852, 0.504914841849148, 0.644914841849148, 
-1.37508515815085, -0.00508515815085175, -2.52508515815085, 0.964914841849148, 
-0.205085158150852), investor_count.cent = c(NA, -2.98954703832753, 
NA, 0.010452961672474, 0.010452961672474, 7.01045296167247, -2.98954703832753, 
-2.98954703832753, -0.989547038327526, -0.989547038327526), communion.cent = c(1.37408759124088, 
0.294087591240876, 0.244087591240876, -0.705912408759124, -1.04591240875912, 
-1.34591240875912, 3.02408759124088, -1.57591240875912, 1.38408759124088, 
-0.115912408759124), gender_d.cent = c(-0.868292682926829, 0.131707317073171, 
0.131707317073171, 0.131707317073171, 0.131707317073171, 0.131707317073171, 
0.131707317073171, 0.131707317073171, 0.131707317073171, 0.131707317073171
), first_time_founder_d.cent = c(0.339152119700748, 0.339152119700748, 
0.339152119700748, 0.339152119700748, -0.660847880299252, -0.660847880299252, 
-0.660847880299252, -0.660847880299252, -0.660847880299252, 0.339152119700748
), num_years_in_business.cent = c(-0.821818696683303, 0.657633358111217, 
0.531605960850943, -0.271133765176454, -0.94510636791618, -0.698531025450427, 
-1.323188559697, 0.065852536193409, -1.19990088846413, -0.8245584227107
), statuses_count.cent = c(-4267.79562043796, -5839.79562043796, 
4351.20437956204, -7041.79562043796, 1050.20437956204, 38029.204379562, 
8841.20437956204, -5565.79562043796, -5996.79562043796, -4602.79562043796
)), row.names = c(NA, -10L), class = "data.frame")

标签: rggplot2

解决方案


推荐阅读