Tate Art [Data Visualization]
By Oliver C. Stringham in tidy-tuesday data-visualization r
January 15, 2021
#TidyTuesday dataset of the week is the art collection of Tate Art Museum. I made a visual of the number of acquisitions made by Tate by decade taking into account what decade the art was created. The top plot tracks the number of acquisition made by Tate per decade. In the bottom plot, the x-axis is the decade Tate acquired a piece, the y-axis is the decade the piece was created, and each rectangle represents the number of acquisitions made. Hover over the data points to see their values. I used ggplot in R to generate the plot and ggiraph to convert it to a HTML widget. Code below plot.
R Code
library(readr)
library(dplyr)
library(glue)
library(ggplot2)
library(plotly)
library(ggiraph)
library(scales)
library(htmlwidgets)
library(egg)
library(patchwork)
# load in data
artwork <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-01-12/artwork.csv')
artists <- readr::read_csv("https://github.com/tategallery/collection/raw/master/artist_data.csv")
# types of art
art_type = artwork %>% distinct(medium) %>% arrange(medium)
# combine to one df
df = artwork %>%
left_join(artists, by = c("artistId" = "id"))
# tile plot of yr created vs yr acquired
p2 =
df %>%
filter(acquisitionYear < 2010) %>%
filter(year <= acquisitionYear) %>%
mutate(decade_create = floor(year/10)*10,
decade_acquired = floor(acquisitionYear/10)*10) %>%
group_by(decade_create, decade_acquired) %>%
summarise(n = n()) %>%
mutate(hover = glue("Decade Created: {decade_create}\n",
"Decade Acquired: {decade_acquired}\n",
"Acquisitions: {comma(n, accuracy = 1)}")) %>%
ggplot(aes(x = decade_acquired, y = decade_create, fill = log10(n))) +
geom_tile_interactive(color = "gray", aes(tooltip = hover, data_id = decade_acquired)) +
geom_abline(slope = 1) +
scale_fill_fermenter(direction = 1, palette = 3, labels = comma(c(10, 100, 1000), accuracy = 1)) +
labs(fill = "Number of\nAcquisitions",
y = "Decade of Creation",
x = "Decade of Acquisition") +
theme(
# plot.title = element_text(face = "bold", size = 12),
panel.background = element_rect(fill = "white", color = "gray50"),
legend.background = element_rect(fill = "white", size = 4, colour = "white"),
# legend.justification = c(0, 1),
# legend.position = "bottom", # c(0, 1),
axis.ticks = element_line(colour = "grey70", size = 0.2),
panel.grid.major = element_line(colour = "grey70", size = 0.2),
panel.grid.minor = element_blank()
) +
NULL
# p2
# ## test ggiraph
# x = girafe(code = print(p2))
# x
# line plot per decade
p3 =
df %>%
filter(acquisitionYear < 2010) %>%
filter(year <= acquisitionYear) %>%
mutate(decade_acquired = floor(acquisitionYear/10)*10) %>%
group_by(decade_acquired) %>%
summarise(n = n()) %>%
mutate(hover = glue("{decade_acquired}s: {comma(n, accuracy = 1)} acquisitions")) %>%
ggplot(aes(x = decade_acquired, y = n)) +
geom_line(color = 'grey') +
geom_point_interactive(aes(tooltip = hover, data_id = decade_acquired)) +
scale_y_continuous(trans = 'log10', labels = comma) +
labs(x = "", y = "Number of\nAcquisitions") +
theme(
# plot.title = element_text(face = "bold", size = 12),
panel.background = element_rect(fill = "white", color = "gray50"),
legend.background = element_rect(fill = "white", size = 4, colour = "white"),
# legend.justification = c(0, 1),
# legend.position = "bottom", # c(0, 1),
axis.ticks = element_line(colour = "grey70", size = 0.2),
panel.grid.major = element_line(colour = "grey70", size = 0.2),
panel.grid.minor = element_blank()
) +
NULL
# p3
# combine to one plot
p_all = p3 / p2 + plot_layout(heights = c(1, 4))
# p_all
# to girafe
g = girafe(code = print(p_all),
options = list(
opts_hover_inv(css = "opacity:0.25;"),
opts_hover(css = "stroke-width:0.5;")
))
g
# # save as html
# saveWidget(g, file = "plots/art.html", selfcontained = TRUE)
# saveRDS(g, 'plot.rds')