library(tidyverse)
df_leafs <- read_csv("./data/sls_results.csv")
trunk_height <- 13 #Intercept
trunk_pos1 <- 20
df_tree <-
df_leafs %>%
mutate(Group = case_when(
Group == "Control" ~ trunk_pos1,
Group == "Group 1" ~ 2*trunk_pos1,
Group == "Group 2" ~ 3*trunk_pos1,
Group == "Group 3" ~ 4*trunk_pos1)) %>%
mutate(leaf_leng = if_else(Group == trunk_pos1, 1, Estimate + 1),
leaf_x = case_when(
outcome == "Letter Names" ~ Group - leaf_leng,
outcome == "Letter Sounds" ~ Group - leaf_leng,
outcome == "Invented words" ~ Group + leaf_leng,
outcome == "Familiar words" ~ Group + leaf_leng,
outcome == "Oral reading" ~ Group + leaf_leng),
leaf_y = case_when(
outcome == "Letter Names" ~ trunk_height - leaf_leng,
outcome == "Letter Sounds" ~ trunk_height,
outcome == "Invented words" ~ trunk_height + leaf_leng,
outcome == "Familiar words" ~ trunk_height,
outcome == "Oral reading" ~ trunk_height - leaf_leng),
leaf_pos = case_when(
outcome == "Letter Names" ~ "left",
outcome == "Letter Sounds" ~ "left",
outcome == "Invented words" ~ "right",
outcome == "Familiar words" ~ "right",
outcome == "Oral reading" ~ "right"))
mytheme <-
theme(
axis.text.x = element_text(size = 18),
legend.text = element_text(size = 11),
plot.background = element_rect(fill = '#f0ebe7', colour = NA),
plot.margin = margin(15, 80, 15, 80),
panel.background = element_rect(fill = '#f0ebe7', colour = NA))
gg_palmtree <-
df_tree %>%
ggplot(aes(x = Group, xend = leaf_x, y = trunk_height, yend = leaf_y,
color = outcome))+
geom_curve(aes(x = Group, xend = Group, y = 0, yend = trunk_height),
curvature = 0.2, size = 1.5,
color = '#5F5D36', lineend = "round")+
geom_curve(data = subset(df_tree,leaf_pos == "left"),
curvature = 0.6, lineend = "round", size = 4) +
geom_curve(data = subset(df_tree,leaf_pos == "right"),
curvature = -0.6, lineend = "round", size = 4) +
scale_x_continuous(breaks = c(trunk_pos1, 2*trunk_pos1, 3*trunk_pos1, 4*trunk_pos1),
labels = c("Control", "Group 1", "Group 2", "Group 3"))+
scale_color_brewer(type = "qual", palette = "Dark2",
breaks=c("Letter Names","Letter Sounds",
"Invented words", "Familiar words",
"Oral reading"))+
ylim(0, 20) +
theme_void() +
theme(legend.position = "top",
legend.title = element_blank()) +
mytheme
gg_palmtree