2020-09-24 10:39:48 +00:00
|
|
|
# Plotting
|
|
|
|
## install.packages("tidyverse") <- Not totally necessary.
|
|
|
|
## install.packages("ggplot2")
|
2021-03-09 17:04:26 +00:00
|
|
|
|
2020-09-24 10:39:48 +00:00
|
|
|
library(ggplot2)
|
2021-03-09 17:04:26 +00:00
|
|
|
library(ggsci) ## Used for scales
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
## General variables
|
|
|
|
saveplots=TRUE
|
2021-03-09 17:04:26 +00:00
|
|
|
### saveplots=FALSE
|
|
|
|
### shootingtype="reverse"
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
shootingtype="forward"
|
|
|
|
utilityfunction="ConstantElasticityOfSubstitution"
|
|
|
|
directory = paste("/home/nuno/Documents/core/srf/fresh/simulations/rcode/", utilityfunction, "/plots/", shootingtype, "shooting", last, "years", sep="")
|
|
|
|
|
|
|
|
directory
|
|
|
|
setwd(directory)
|
|
|
|
getwd()
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
height = 5
|
|
|
|
width = floor(height*(1+sqrt(5))/2)
|
|
|
|
imagenumbercounter = 1
|
|
|
|
saveplot = function(imagename){
|
|
|
|
if(saveplots){
|
|
|
|
ggsave(paste(imagenumbercounter,"_", imagename, "_",shootingtype, "shooting",".png", sep =""), units="in", width=width, height=height)
|
|
|
|
imagenumbercounter <<- imagenumbercounter+1
|
|
|
|
## https://stackoverflow.com/questions/1236620/global-variables-in-r
|
|
|
|
}
|
|
|
|
}
|
|
|
|
options(digits=1) ## Just for display
|
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## Data
|
|
|
|
if(shootingtype=="forward"){
|
|
|
|
K_array_plotting <- K_array_forward_shooting
|
|
|
|
L_array_plotting <- L_array_forward_shooting
|
|
|
|
k1_array_plotting <- k1_array_forward_shooting
|
|
|
|
k2_array_plotting <- k2_array_forward_shooting
|
|
|
|
wages_array_plotting <- -wages_array_forward_shooting
|
|
|
|
l1_array_plotting <- l1_array_forward_shooting
|
|
|
|
l2_array_plotting <- l2_array_forward_shooting
|
|
|
|
} else if(shootingtype=="reverse"){
|
|
|
|
K_array_plotting <- K_array_reverse_shooting
|
|
|
|
L_array_plotting <- L_array_reverse_shooting
|
|
|
|
k1_array_plotting <- k1_array_reverse_shooting
|
|
|
|
k2_array_plotting <- k2_array_reverse_shooting
|
|
|
|
l1_array_plotting <- l1_array_reverse_shooting
|
|
|
|
l2_array_plotting <- l2_array_reverse_shooting
|
|
|
|
}
|
|
|
|
|
|
|
|
## K and L
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
xs <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
xs$values <- c(K_array_plotting, L_array_plotting)
|
|
|
|
xs$var <- c(rep("K", length(K_array_plotting)), rep("L", length(L_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
xs$times = rep(times,2)
|
|
|
|
xs <- as.data.frame(xs)
|
|
|
|
title_text = "Evolution of state variables"
|
|
|
|
(ggplot(data = xs, aes(x = times, y= values, color = var)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+ labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Capital and labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.box="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("K", "L"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Capital", "Labor")
|
|
|
|
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
+ scale_y_continuous(breaks = seq(min(K_array_plotting), max(K_array_plotting), length.out=5))
|
2020-09-24 10:39:48 +00:00
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("StateVariablesKL")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## K and L: log plot
|
2020-09-24 10:39:48 +00:00
|
|
|
title_text = "Evolution of state variables"
|
|
|
|
(ggplot(data = xs, aes(x = times, y= values, color = var)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
subtitle="(logarithmic scale)",
|
|
|
|
x="Year since start",
|
|
|
|
y="Capital and labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
|
|
|
legend.position="bottom",
|
|
|
|
legend.box="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("K", "L"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Capital", "Labor")
|
|
|
|
|
|
|
|
)
|
|
|
|
+ scale_y_continuous(trans = 'log2')
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("StateVariablesKLlogplot")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## Only L
|
|
|
|
equil2 <- list()
|
|
|
|
equil2$values <- c(L_array_plotting)
|
|
|
|
equil2$times = times
|
|
|
|
equil2 <- as.data.frame(equil2)
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
title_text = "Evolution of movement size"
|
2021-03-09 17:04:26 +00:00
|
|
|
(ggplot(data = equil2, aes(x = times, y= values))
|
2020-09-24 10:39:48 +00:00
|
|
|
+geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.box="vertical"
|
|
|
|
)
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("StateVariableL")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## l1, l2, s4
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmas <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
s4_array_plotting=1-l1_array_plotting-l2_array_plotting
|
|
|
|
sigmas$values <- c(l1_array_plotting, l2_array_plotting,s4_array_plotting)
|
|
|
|
sigmas$fraction <- c(rep("l1", length(l1_array_plotting)), rep("l2", length(l2_array_plotting)),rep("s4", length(l2_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmas$times = rep(times,3)
|
|
|
|
sigmas <- as.data.frame(sigmas)
|
|
|
|
|
|
|
|
title_text = "Evolution of labor fractions"
|
|
|
|
(ggplot(data = sigmas, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Fraction of total labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("l1", "l2", "s4"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Direct work", "Movement building", "Money-making")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
saveplot("MovementFractions")
|
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## l1 and l2
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmas <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
sigmas$values <- c(l1_array_plotting, l2_array_plotting)
|
|
|
|
sigmas$fraction <- c(rep("l1", length(l1_array_plotting)), rep("l2", length(l2_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmas$times = rep(times,2)
|
|
|
|
sigmas <- as.data.frame(sigmas)
|
|
|
|
|
|
|
|
title_text = "Evolution of labor fractions"
|
|
|
|
subtitle_text = "(only direct work and movement building)"
|
|
|
|
(ggplot(data = sigmas, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
subtitle=subtitle_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Fraction of total labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("l1", "l2"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Direct work", "Movement building")
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementFractionsl1l2")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
## Just direct work.
|
2021-03-09 17:04:26 +00:00
|
|
|
sigma_1 <- list()
|
|
|
|
sigma_1$values <- c(l1_array_plotting)
|
|
|
|
sigma_1$times = times
|
|
|
|
sigma_1 <- as.data.frame(sigma_1)
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
title_text = "Evolution of direct work \nas a fraction of total labor"
|
2021-03-09 17:04:26 +00:00
|
|
|
(ggplot(data = sigma_1, aes(x = times, y= values))
|
2020-09-24 10:39:48 +00:00
|
|
|
+geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Fraction of total labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.box="vertical"
|
|
|
|
)
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementFractionsl1")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Just movement building
|
2021-03-09 17:04:26 +00:00
|
|
|
sigma_2 <- list()
|
|
|
|
sigma_2$values <- c(l2_array_plotting)
|
|
|
|
sigma_2$times = times
|
|
|
|
sigma_2 <- as.data.frame(sigma_2)
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
title_text = "Evolution of movement building\nas a fraction of total labor"
|
2021-03-09 17:04:26 +00:00
|
|
|
(ggplot(data = sigma_2, aes(x = times, y= values))
|
2020-09-24 10:39:48 +00:00
|
|
|
+geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Fraction of labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.box="vertical"
|
|
|
|
)
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementFractionsl2")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
## Just direct work - logplot
|
2021-03-09 17:04:26 +00:00
|
|
|
sigma_1 <- list()
|
|
|
|
sigma_1$values <- c(l1_array_plotting)
|
|
|
|
sigma_1$times = times
|
|
|
|
sigma_1 <- as.data.frame(sigma_1)
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
title_text = "Evolution of direct work \nas a fraction of labor"
|
2021-03-09 17:04:26 +00:00
|
|
|
(ggplot(data = sigma_1, aes(x = times, y= values))
|
2020-09-24 10:39:48 +00:00
|
|
|
+geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
subtitle="(logarithmic scale)",
|
|
|
|
x="Year since start",
|
|
|
|
y="Fraction of labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.box="vertical"
|
|
|
|
)
|
|
|
|
+ scale_y_continuous(trans = 'log2')
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementFractionsl1logplot")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
## Just movement building
|
2021-03-09 17:04:26 +00:00
|
|
|
sigma_2 <- list()
|
|
|
|
sigma_2$values <- c(l2_array_plotting)
|
|
|
|
sigma_2$times = times
|
|
|
|
sigma_2 <- as.data.frame(sigma_2)
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
title_text = "Evolution of movement building\nas a fraction of labor"
|
2021-03-09 17:04:26 +00:00
|
|
|
(ggplot(data = sigma_2, aes(x = times, y= values))
|
2020-09-24 10:39:48 +00:00
|
|
|
+geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
subtitle="(logarithmic scale)",
|
|
|
|
x="Year since start",
|
|
|
|
y="Fraction of total labor"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
|
|
|
legend.position="bottom",
|
|
|
|
legend.box="vertical"
|
|
|
|
)
|
|
|
|
+ scale_y_continuous(trans = 'log2')
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementFractionsl2logplot")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## sigma_1*L and sigma_2*L, sigma_4*L,
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmaxs <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
sigmaxs$values <- c(l1_array_plotting*L_array_plotting, l2_array_plotting*L_array_plotting, s4_array_plotting*L_array_plotting)
|
|
|
|
sigmaxs$fraction <- c(rep("l1L", length(l1_array_plotting)), rep("l2L", length(l2_array_plotting)), rep("s4L", length(l2_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmaxs$times = rep(times,3)
|
|
|
|
sigmaxs <- as.data.frame(sigmaxs)
|
|
|
|
|
|
|
|
title_text = "Evolution of labor\n in absolute terms"
|
|
|
|
(ggplot(data = sigmaxs, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Absolute number\nof movement participants"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("l1L", "l2L", "s4L"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Direct work", "Movement building", "Money-making")
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementParticipantNumbersl1l2S4")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## sigma_1*L and sigma_2*L
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmaxs <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
sigmaxs$values <- c(l1_array_plotting*L_array_plotting, l2_array_plotting*L_array_plotting)
|
|
|
|
sigmaxs$fraction <- c(rep("l1L", length(l1_array_plotting)), rep("l2L", length(l2_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmaxs$times = rep(times,2)
|
|
|
|
sigmaxs <- as.data.frame(sigmaxs)
|
|
|
|
|
|
|
|
title_text = "Evolution of movement participants\nin absolute terms"
|
|
|
|
(ggplot(data = sigmaxs, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
subtitle="(only direct workers and movement builders)",
|
|
|
|
x="Year since start",
|
|
|
|
y="Absolute number\nof movement participants"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("l1L", "l2L"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Direct work", "Movement building")
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementParticipantNumbersl1l2")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## sigma_1*L and sigma_2*L logplot
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmaxs <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
sigmaxs$values <- c(l1_array_plotting*L_array_plotting, l2_array_plotting*L_array_plotting)
|
|
|
|
sigmaxs$fraction <- c(rep("l1L", length(l1_array_plotting)), rep("l2L", length(l2_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
sigmaxs$times = rep(times,2)
|
|
|
|
sigmaxs <- as.data.frame(sigmaxs)
|
|
|
|
|
|
|
|
title_text = "Evolution of movement participants\nin absolute terms \n(logarithmic scale)"
|
|
|
|
(ggplot(data = sigmaxs, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
subtitle="(only direct workers and movement builders)",
|
|
|
|
x="Year since start",
|
|
|
|
y="Absolute number\nof movement participants"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("l1L", "l2L"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Direct work", "Movement building")
|
|
|
|
|
|
|
|
)
|
|
|
|
+ scale_y_continuous(trans = 'log2')
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("MovementParticipantNumbersl1l2logplot")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## alpha1 and alpha2
|
2020-09-24 10:39:48 +00:00
|
|
|
alphas <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
alphas$values <- c(k1_array_plotting, k2_array_plotting)
|
|
|
|
alphas$fraction <- c(rep("k1", length(l1_array_plotting)), rep("k2", length(l2_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
alphas$times = rep(times,2)
|
|
|
|
alphas <- as.data.frame(alphas)
|
|
|
|
|
|
|
|
title_text = "Evolution of spending"
|
|
|
|
(ggplot(data = alphas, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Spending"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
2021-03-09 17:04:26 +00:00
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
2020-09-24 10:39:48 +00:00
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("k1", "k2"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Direct spending","Spending on movement building")
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("Spendingk1k2")
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
## alphk1 and alphk2: log plot
|
2020-09-24 10:39:48 +00:00
|
|
|
|
|
|
|
alphas <- list()
|
2021-03-09 17:04:26 +00:00
|
|
|
alphas$values <- c(k1_array_plotting, k2_array_plotting)
|
|
|
|
alphas$fraction <- c(rep("k1", length(l1_array_plotting)), rep("k2", length(l2_array_plotting)))
|
2020-09-24 10:39:48 +00:00
|
|
|
alphas$times = rep(times,2)
|
|
|
|
alphas <- as.data.frame(alphas)
|
|
|
|
|
|
|
|
title_text = "Evolution of spending"
|
|
|
|
(ggplot(data = alphas, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
subtitle="(logarithmic scale)",
|
|
|
|
x="Year since start",
|
|
|
|
y="Spending"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
2021-03-09 17:04:26 +00:00
|
|
|
breaks=c("k1", "k2"),
|
2020-09-24 10:39:48 +00:00
|
|
|
labels=c("Direct spending","Spending on movement building")
|
|
|
|
)
|
|
|
|
+ scale_y_continuous(trans = 'log2')
|
|
|
|
)
|
2021-03-09 17:04:26 +00:00
|
|
|
saveplot("Spendingk1k2logplot")
|
|
|
|
|
|
|
|
## alpha1 and alpha2 and wages
|
|
|
|
alphas <- list()
|
|
|
|
alphas$values <- c(k1_array_plotting, k2_array_plotting, wages_array_plotting)
|
|
|
|
alphas$fraction <- c(rep("k1", length(l1_array_plotting)), rep("k2", length(l2_array_plotting)), rep("wages", length(wages_array_plotting)))
|
|
|
|
alphas$times = rep(times,3)
|
|
|
|
alphas <- as.data.frame(alphas)
|
2020-09-24 10:39:48 +00:00
|
|
|
|
2021-03-09 17:04:26 +00:00
|
|
|
title_text = "Evolution of spending"
|
|
|
|
(ggplot(data = alphas, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Spending"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
|
|
|
breaks=c("k1", "k2", "wages"),
|
|
|
|
labels=c("Direct spending","Spending on movement building", "Spending on wages")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
saveplot("Spendingk1k2k3")
|
|
|
|
|
|
|
|
|
|
|
|
## alpha1 and alpha2 and wages: logplot
|
|
|
|
alphas <- list()
|
|
|
|
alphas$values <- c(k1_array_plotting, k2_array_plotting, wages_array_plotting)
|
|
|
|
alphas$fraction <- c(rep("k1", length(l1_array_plotting)), rep("k2", length(l2_array_plotting)), rep("wages", length(wages_array_plotting)))
|
|
|
|
alphas$times = rep(times,3)
|
|
|
|
alphas <- as.data.frame(alphas)
|
|
|
|
|
|
|
|
title_text = "Evolution of spending"
|
|
|
|
(ggplot(data = alphas, aes(x = times, y= values, color = fraction)) +
|
|
|
|
geom_line(size = 0.5)
|
|
|
|
+labs(
|
|
|
|
title=title_text,
|
|
|
|
x="Year since start",
|
|
|
|
y="Spending"
|
|
|
|
)
|
|
|
|
+theme(
|
|
|
|
legend.title = element_blank(),
|
|
|
|
plot.title = element_text(hjust = 0.5),
|
|
|
|
plot.subtitle = element_text(hjust = 0.5),
|
|
|
|
legend.position="bottom",
|
|
|
|
legend.direction="vertical"
|
|
|
|
)
|
|
|
|
+ scale_color_lancet(
|
|
|
|
breaks=c("k1", "k2", "wages"),
|
|
|
|
labels=c("Direct spending","Spending on movement building", "Spending on wages")
|
|
|
|
)
|
|
|
|
+ scale_y_continuous(trans = 'log2')
|
|
|
|
)
|
|
|
|
saveplot("Spendingk1k2k3_logplot")
|