set.seed(1)
player_colors = c("#e46f27", "#7f659f", "#1c4a7a")
selection = c("T:1 S:313 A:FFF",
"T:2 S:221 A:TTF",
"T:3 S:331 A:TTF",
"T:3 S:133 A:FFF",
"T:3 S:213 A:FFF",
"T:3 S:213 A:FTF",
"T:3 S:112 A:FFF",
"T:3 S:112 A:FTF",
"T:3 S:322 A:FTT",
"T:3 S:223 A:FFF")
df.plot = df.exp3b.selection %>%
mutate(across(contains("action"),
~ factor(., levels = c("fish", "trees"),
labels = c("F", "T"))),
label = str_c("T:", trees,
" S:", strength_a, strength_b, strength_c,
" A:", action_a, action_b, action_c)) %>%
mutate(label = factor(label,
levels = selection,
labels = selection)) %>%
filter(label %in% selection)
df.text = df.plot %>%
select(-c(trial, judgment, player)) %>%
distinct() %>%
pivot_longer(cols = -c(trees, label),
names_to = c("type", "player"),
values_transform = list(value = as.character),
names_sep = "_",
values_to = "value") %>%
pivot_wider(names_from = type,
values_from = value)
df.index = df.text %>%
distinct(label) %>%
arrange(label) %>%
mutate(index = 1:n(),
player = NA)
df.trees = df.plot %>%
select(label, trees) %>%
distinct() %>%
mutate(tree = map(.x = trees,
.f = ~ rep(fontawesome("fa-tree"), .x) %>%
str_flatten()),
player = NA)
df.model = df.plot %>%
group_by(trial, label) %>%
summarize(judgment = mean(judgment)) %>%
ungroup() %>%
left_join(df.exp3b.model.pivotality,
by = c("trial")) %>%
left_join(df.exp3b.model.rationality,
by = c("trial")) %>%
mutate(model_pivotality = lm(formula = judgment ~ pivotality,
data = .)$fitted.values,
model_rationality = lm(formula = judgment ~ rationality,
data = .)$fitted.values,
model_full = lm(formula = judgment ~ pivotality + rationality,
data = .)$fitted.values) %>%
select(-c(judgment, pivotality, rationality)) %>%
pivot_longer(cols = -c(trial, label),
names_to = "model",
values_to = "judgment") %>%
mutate(player = str_sub(trial, -1),
player = factor(player,
levels = 0:2,
labels = letters[1:3])) %>%
filter(model == "model_full")
ggplot(data = df.plot,
mapping = aes(x = player,
y = judgment,
fill = player)) +
stat_summary(fun.data = "mean_cl_boot",
geom = "pointrange",
shape = 21,
size = 0.75,
show.legend = F) +
geom_point(mapping = aes(color = player),
position = position_jitter(width = 0.1, height = 0),
alpha = 0.1,
show.legend = F) +
geom_point(data = df.model,
alpha = 1,
shape = 1,
color = "black",
size = 3,
show.legend = F) +
geom_text(data = df.text,
mapping = aes(y = 1.15,
x = player,
label = strength),
size = 6) +
geom_text(data = df.text,
mapping = aes(y = 1.05,
x = player,
label = action),
size = 6) +
geom_text(data = df.trees,
mapping = aes(y = 1.26,
x = 2,
label = tree),
family = 'fontawesome-webfont',
size = 6,
color = "darkgreen") +
geom_text(data = df.index,
mapping = aes(y = 1.4,
x = 2,
label = index),
size = 10) +
facet_grid(~ label) +
scale_y_continuous(breaks = seq(0, 1, 0.25),
labels = seq(0, 100, 25)) +
scale_fill_manual(values = player_colors) +
scale_color_manual(values = player_colors) +
# scale_shape_manual(values = 22:24) +
scale_x_discrete(labels = c("A", "B", "C")) +
coord_cartesian(ylim = c(0, 1),
clip = "off") +
labs(x = "fisherman",
y = "blame judgment") +
theme(strip.text = element_blank(),
strip.background = element_blank(),
panel.grid.major.y = element_line(),
panel.spacing = unit(0.75, "cm"),
plot.margin = margin(t = 3, b = 0.5, l = 0.5, r = 0.5, "cm"))
ggsave("../../figures/paper/figure11.pdf",
width = 20,
height = 5)