-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_avida_popstacks.R
executable file
·27 lines (21 loc) · 1.06 KB
/
plot_avida_popstacks.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env Rscript
source("analysis/common.R")
r10data <- read_csv("data/coop_cheats_r010_411.csv") %>%
mutate(Resource = 10)
r30data <- read_csv("data/coop_cheats_r030_411.csv") %>%
mutate(Resource = 30)
alldata <- bind_rows(r10data, r30data)
alldata$Type <- factor(alldata$Type, levels = c("Cooperator", "Cheater"))
res_labels <- c("10" = "(a) Resource Level 10", "30" = "(b) Resource Level 30")
p_stack <- ggplot(data = alldata,
aes(x = Update / 1000, y = Abundance, color = Type,
fill = Type)) +
geom_area(position = "stack") +
facet_grid(~ Resource, labeller = labeller(Resource = res_labels)) +
scale_y_continuous(lim = c(0, 10000)) +
scale_color_manual(values = type_colors, name = type_name) +
scale_fill_manual(values = type_colors, name = type_name) +
labs(x = label_time, y = label_abundance) +
theme(aspect.ratio = 2 / (1 + sqrt(5)))
ggsave(filename = "figures/avida_population_stacks.pdf", plot = p_stack)
trim_whitespace(filename = "figures/avida_population_stacks.pdf", margins = 1)