tweak: automatically plot clean-labels version
This commit is contained in:
parent
7d9bd15f86
commit
3f1cee9c36
|
@ -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)
|
||||||
|
|
||||||
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_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,
|
||||||
|
@ -177,9 +181,18 @@ open_philanthropy_plot_with_fortune <- ggplot(data=df2, aes(x=year, y=amount, fi
|
||||||
legend.text=element_text(size=8)
|
legend.text=element_text(size=8)
|
||||||
) +
|
) +
|
||||||
guides(fill=guide_legend(nrow=4,byrow=TRUE))
|
guides(fill=guide_legend(nrow=4,byrow=TRUE))
|
||||||
# open_philanthropy_plot_with_fortune
|
# open_philanthropy_plot_with_fortune
|
||||||
|
|
||||||
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 |
Loading…
Reference in New Issue
Block a user