#' Count exhibitions per year and per type
#'
#' @param .exhibitions a data frames of exhibitions
#' @param .exhplaces a data frame of exhibition venues
#'
#' @return a ggplot object
#' @export
#'
#' @examples
#' plot <- plot_exh_count_per_venue_type(exhibitions, exhplaces, file_out("figures/plot_exh_count_per_venue_type.pdf"))
plot_exh_count_per_venue_type <- function(.exhibitions, .exhplaces, .filename){
plot <- .exhibitions %>%
# count exhibitions per year on node level
group_by(exh_place_id, exh_start_Y) %>%
summarise(exh.per.year = n_distinct(id)) %>%
left_join(.exhplaces, c("exh_place_id" = "id")) %>%
# create bar chart
ggplot(aes(x = exh_start_Y, y = exh.per.year, fill = type_exhplace)) +
geom_col() +
# customize layout
theme_minimal() +
scale_x_continuous(limits = c(1900, 2015)) +
labs(x = "Year",
y = "Number of Exhibitions",
fill = "Venue Type")
ggsave(.filename,
plot,
width = 7, height = 5)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.