tweak: automatically plot clean-labels version

This commit is contained in:
Leopold Tal G 2022-11-22 08:18:39 +11:00
parent 7d9bd15f86
commit 3f1cee9c36
2 changed files with 60 additions and 47 deletions

View File

@ -133,9 +133,13 @@ coeff <- 10^7*4
wealth <- c(6, 8, 12, 15, 18, 12, 14, 19, 14) wealth <- c(6, 8, 12, 15, 18, 12, 14, 19, 14)
df2$wealth <- rep(wealth * coeff, num_areas) df2$wealth <- rep(wealth * coeff, num_areas)
make_fortune_plot <- function(show_fortune_legend = FALSE) {
open_philanthropy_plot_with_fortune <- ggplot(data=df2, aes(x=year, y=amount, fill=area))+ open_philanthropy_plot_with_fortune <- ggplot(data=df2, aes(x=year, y=amount, fill=area))+
geom_bar(stat="identity")+ geom_bar(stat="identity")+
geom_point(aes(x=year, y=wealth), size=2, color="darkblue", shape=4)+ geom_point(
aes(x=year, y=wealth), size=2, color="darkblue", shape=4,
show.legend=show_fortune_legend
)+
labs( labs(
title=title_text, title=title_text,
subtitle=subtitle_text, subtitle=subtitle_text,
@ -182,4 +186,13 @@ open_philanthropy_plot_with_fortune <- ggplot(data=df2, aes(x=year, y=amount, fi
height = 6 height = 6
width = 5 width = 5
ggsave(plot=open_philanthropy_plot_with_fortune, "open_philanthropy_plot_with_fortune.png", width=width, height=height, bg = "white") filename = ifelse(
show_fortune_legend,
"open_philanthropy_plot_with_fortune.png",
"open_philanthropy_plot_with_fortune_clean_labels.png"
)
ggsave(plot=open_philanthropy_plot_with_fortune, filename, width=width, height=height, bg = "white")
}
make_fortune_plot(TRUE)
make_fortune_plot(FALSE)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 182 KiB