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)
df2$wealth <- rep(wealth * coeff, num_areas)
open_philanthropy_plot_with_fortune <- ggplot(data=df2, aes(x=year, y=amount, fill=area))+
make_fortune_plot <- function(show_fortune_legend = FALSE) {
open_philanthropy_plot_with_fortune <- ggplot(data=df2, aes(x=year, y=amount, fill=area))+
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(
title=title_text,
subtitle=subtitle_text,
@ -177,9 +181,18 @@ open_philanthropy_plot_with_fortune <- ggplot(data=df2, aes(x=year, y=amount, fi
legend.text=element_text(size=8)
) +
guides(fill=guide_legend(nrow=4,byrow=TRUE))
# open_philanthropy_plot_with_fortune
# open_philanthropy_plot_with_fortune
height = 6
width = 5
height = 6
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