Compare commits

...

2 Commits

@ -0,0 +1,512 @@
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.3, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
height = 5
width = 5
ggsave(plot=open_philanthropy_plot, "open_philanthropy_grants_stacked_with_amounts.png", width=width, height=height, bg = "white")
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), ""), colour="white"), size = 2, position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, colour="white", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, colour="#D3D3D3", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, colour="#C2C2C2", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, colour="#D3D3D3", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
height = 5
width = 5
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, colour="#f9f9f9", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, group = cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"), breaks = c(0:6)*10^8)+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 1.7, colour="#f9f9f9", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
height = 5
width = 5
ggsave(plot=open_philanthropy_plot, "open_philanthropy_grants_stacked_with_amounts.png", width=width, height=height, bg = "white")
open_philanthropy_plot_lt <- ggplot(data=df4, aes(x=year, y=amount, fill=area, group=cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"))+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7)
) +
geom_text(aes(label=ifelse(amount > 5e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 1.7, colour="#f9f9f9", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.3, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot_lt
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
height = 5
width = 6
## open_philanthropy_plot_lt
ggsave(plot=open_philanthropy_plot_lt, "open_philanthropy_grants_lt_labeled.png", width=width, height=height, bg = "white")
open_philanthropy_plot_lt <- ggplot(data=df4, aes(x=year, y=amount, fill=area, group=cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"))+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7)
) +
geom_text(aes(fill="#f9f9f9", label=ifelse(amount > 5e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 1.7, position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.3, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot_lt
open_philanthropy_plot_lt <- ggplot(data=df4, aes(x=year, y=amount, fill=area, group=cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"))+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7)
) +
geom_text(aes(label=ifelse(amount > 5e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 1.7, position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.3, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot_lt
open_philanthropy_plot_lt <- ggplot(data=df4, aes(x=year, y=amount, fill=area, group=cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"))+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7)
) +
geom_text(aes(label=ifelse(amount > 5e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 1.7, colour="#f9f9f9", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.3, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot_lt
open_philanthropy_plot_lt <- ggplot(data=df4, aes(x=year, y=amount, fill=area, group=cummulative_amount_for_its_area))+
geom_bar(stat="identity")+
labs(
title=title_text,
subtitle=subtitle_text,
x=element_blank(),
y=element_blank()
) +
# scale_fill_wsj() +
# scale_fill_tableau(dir =1) +
# scale_fill_tableau(palette, dir=direction) +
# scale_fill_viridis(discrete = TRUE) +
# scale_fill_brewer(palette = "Set2") +
scale_fill_d3( "category20", alpha=0.8) +
# scale_fill_uchicago("dark") +
# scale_fill_startrek() +
scale_y_continuous(labels = scales::dollar_format(scale = 0.000001, suffix = "M"))+
scale_x_continuous(breaks = years)+
theme_tufte() +
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",
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7)
) +
geom_text(aes(label=ifelse(amount > 5e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, colour="#f9f9f9", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.3, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot_lt
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
height = 5
width = 6
## open_philanthropy_plot_lt
ggsave(plot=open_philanthropy_plot_lt, "open_philanthropy_grants_lt_labeled.png", width=width, height=height, bg = "white")

@ -15,7 +15,7 @@ library("RColorBrewer")
library("ggsci")
## Data import
setwd("/home/loki/Documents/core/ea/fresh/misc/openphil-funding")
setwd("/home/loki/Blog/nunosempere.com/blog/2022/11/20/brief-update-ea-funding/.source")
data <- read.csv("grants.csv", header=TRUE, stringsAsFactors = FALSE)
## Data cleaning
@ -84,7 +84,7 @@ getAmountForArea(df, "Longtermism & GCRs")
amounts <- c()
for(i in c(1:dim(df2)[1])){
amount <- getAmountForYearAreaPair(df2, df2$year[i], df2$area[i])
amount <- getAmountForYearAreaPair(df, df2$year[i], df2$area[i])
amounts <- c(amounts, amount)
}
df2$amount <- amounts
@ -93,6 +93,7 @@ df2$amount <- amounts
df2$cummulative_amount_for_its_area = sapply(df2$area, function(area) {
return(getAmountForArea(df, area))
})
View(df2)
## Plotting
title_text="Open Philanthropy allocation by year and cause area"
@ -128,12 +129,18 @@ open_philanthropy_plot <- ggplot(data=df2, aes(x=year, y=amount, fill=area, grou
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7, hjust = 0.5)
) +
geom_text(aes(label=ifelse(amount > 25e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 1.7, colour="#f9f9f9", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.2, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
height = 5
width = 5
ggsave(plot=open_philanthropy_plot, "open_philanthropy_grants_stacked.png", width=width, height=height, bg = "white")
ggsave(plot=open_philanthropy_plot, "open_philanthropy_grants_stacked_with_amounts.png", width=width, height=height, bg = "white")
## Including Dustin Moskovitz's wealth
coeff <- 10^7*4
@ -272,9 +279,15 @@ open_philanthropy_plot_lt <- ggplot(data=df4, aes(x=year, y=amount, fill=area, g
axis.text.x=element_text(angle=60, hjust=1),
legend.text=element_text(size=7)
) +
geom_text(aes(label=ifelse(amount > 5e6, paste0(round(amount / 1e6, 0), "M"), "")), size = 2, colour="#f9f9f9", position = position_stack(vjust = 0.5)) +
geom_text(
aes(label = paste0(round(after_stat(y) / 1e6, 0), "M"), group = year),
stat = 'summary', fun = sum, size=2.3, vjust = -0.5
) +
guides(fill=guide_legend(nrow=3,byrow=TRUE))
open_philanthropy_plot_lt
getwd() ## Working directory on which the file will be saved. Can be changed with setwd("/your/directory")
height = 5
width = 6
## open_philanthropy_plot_lt
ggsave(plot=open_philanthropy_plot_lt, "open_philanthropy_grants_lt.png", width=width, height=height, bg = "white")
ggsave(plot=open_philanthropy_plot_lt, "open_philanthropy_grants_lt_labeled.png", width=width, height=height, bg = "white")

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Loading…
Cancel
Save