Infra4NextGen Webinar
Assoc. Prof. for International Relations
University of Innsbruck
Research focus: Foreign and Security Policy; (Counter-)Terrorism; USA, Europe, Austria; social science research methods (v.a. QTA, DNA); academic writing and presentation; open and reproducible science
What is a “visualization”?
Process of visualizing data
RStudio/Jupyter and ggplot2
Example from European Values Study
Visualization
“A visualization is any kind of visual representation of information
designed to enable communication
, analysis, discovery, exploration, etc” [emphasis by FE] (Cairo 2016, 28).
Infographics
“An infographic is a multi-section visual representation
of information intended to communicate one or more specific messages. Infographics are made of a mix of charts, maps, illustrations, and text (or sound) that provides explanation and context.” [emphasis by FE] (Cairo 2016, 31).
“The purpose of infographics and data visualizations is to enlighten people–not to entertain them, not to sell them products, services, or ideas, but to
inform
them.” [Hervorhebung durch FE] (Cairo 2016, 13).
“[It, FE] is about drawing and organizing lines and shapes to communicate a specific bit of science-related information to another person… [It, FE] is about using imagery in the service of communication” (Christiansen 2023, 13).
“data visualisation aims to facilitate understanding” (Kirk 2019, 20).
perceiving
interpreting
comprehending
Principles of Graphical Excellence (Tufte 2007, 51)
“Any visualization is a model” (Cairo 2016, 69)
Use preattentive attributes
to direct observer’s focus.
Visual “[r]epresentation involves making decisions about how you are going to portray your data visually so that the subject understanding it offers can be made accessible to your audience. In simple terms, this is all about charts and the act of selecting the right chart to show the features of your data that you think are most relevant.” (Kirk 2019, 17)
Building blocks of any visualization (Kirk 2019, 17–18):
marks
: Elements used to represent items of data (i.e. points, columns, lines, etc.)attributes
: visual variations of marks to represent the values associated with each (text, color, shape, etc.)see Kirk (2019, 32)
Phase 1: concept
planing and defining project
Phase 2: data
gathering, handling and preparing your data; getting to know the data
Phase 3: "editorial thinking"
defining what you will show your audience; what do we want to communicate (main message)
Phase 4: "Design"
(see Schwabish 2021, 29–45)
“A grammar of graphics is a tool that enables us to concisely describe the components of a graphic. Such a grammar allows us to move beyond named graphics (e.g., the”scatterplot”) and gain insight into the deep structure that underlies statistical graphics.” (Wickham 2010, 3)
plot = data
∩ mapping
mappings comprise 5 elements
Research question:
“How tolerant has Austrian society become over time?”
How to measure
tolerance?
Kritzinger, Sylvia; Aichholzer, Julian; Glavanovits, Josef; Hajdinjak, Sanja; Klaiber, Judith; Seewann, Lena; Friesl, Christian; Zulehner, Paul M., 2019, “European Values Study 1990-2018 Austria Longitudinal Data (SUF edition)”, https://doi.org/10.11587/C4YBOT, AUSSDA, V1.
Questionnaire: 10044_qu_en_v1_0.pdf
## Specifying the API Token we received from AUSSDA
Sys.setenv("DATAVERSE_KEY" = "xyz")
df_evs <-
get_dataframe_by_name(
filename = "10048_da_en_v1_0-1.tab",
dataset = "10.11587/C4YBOT",
.f = haven::read_dta, # for reading SPSS tab file
original = TRUE,
server = "data.aussda.at")
df <- df_evs |> select(Year = S002EVS,
Sex = X001,
Homosexuality = F118) # select variables and rename them
p <- df |>
filter(!is.na(Homosexuality)) |>
group_by(Sex, Year) |>
mutate(mean_Homosexuality =
mean(Homosexuality,
na.rm = TRUE)) |>
ggplot(aes(as_label(Year),
as_label(Homosexuality),
color = as_label(Sex))) +
scale_color_manual(values =
c("#005c8b",
"#E69F00")) +
geom_jitter(alpha = .3) +
geom_point(aes(y = mean_Homosexuality,
color = as_label(Sex)),
size = 5) +
geom_point(aes(y = mean_Homosexuality),
size = 2, color = "white") +
labs(x = "", y = "") +
theme_minimal()
p
fontfamily1 <- "Roboto" # fonts have to be installed on the computer
fontfamily2 <- "Roboto Condensed"
p <- p + labs(title = "<b>Austrian <span style = 'color: #E69F00;'>women</span>
lead the way for <span style = 'color: #005c8b;'>men</span> towards more
tolerance</b>") +
labs(subtitle = "Q: Please tell me whether you think homosexuality can always be justified,
never be justified or something in between.") +
labs(caption = "Source: European Values Study 1990-2018; Austria Longitudinal Data") +
theme(text = element_text(size = 14, family = fontfamily1),
title = element_text(size = 18, family = fontfamily1),
plot.title = element_text(size = 18, family = fontfamily1),
plot.subtitle = element_markdown(size = 14, family = fontfamily2,
margin = ggplot2::margin(1, 0, 1, 0)),
axis.text.x = element_text(size = 12, family = fontfamily1),
axis.text.y = element_text(size = 12, family = fontfamily1),
plot.caption = element_text(size = 10, family = fontfamily1, color = "darkgrey")) +
theme(plot.title = element_markdown(),
plot.subtitle = element_markdown(),
plot.caption = element_markdown(),
panel.grid.major.x = element_blank(),
panel.grid.minor.y = element_blank(),
legend.position="none")
png(filename = "plots/plot_homosexuality-final.png",
width = 21.7,
height = 10.2,
units = "in",
res = 300,
bg = "#ffffff",
type = "cairo-png"
)
df |> filter(!is.na(Homosexuality)) |>
group_by(Sex, Year) |>
mutate(mean_Homosexuality = mean(Homosexuality, na.rm = TRUE)) |>
ggplot(aes(as_label(Year), as_label(Homosexuality), color = as_label(Sex))) +
scale_color_manual(values = c("#005c8b", "#E69F00")) +
geom_jitter(alpha = .3) +
geom_point(aes(y = mean_Homosexuality, color = as_label(Sex)), size = 5) +
geom_point(aes(y = mean_Homosexuality), size = 2, color = "white") +
labs(x = "", y = "") +
labs(title = "<b>Austrian <span style = 'color: #E69F00;'>women</span> lead the way for <span style = 'color: #005c8b;'>men</span> towards more tolerance</b>") +
labs(subtitle = "Q: Please tell me whether you think homosexuality can always be justified, never be justified</span> or something in between.") +
labs(caption = "Source: European Values Study 1990-2018; Austria Longitudinal Data") +
theme_minimal() +
theme(text = element_text(size = 14, family = fontfamily1),
title = element_text(size = 18, family = fontfamily1),
plot.title = element_text(size = 18, family = fontfamily1),
plot.subtitle = element_markdown(size = 14, family = fontfamily2, margin = ggplot2::margin(1, 0, 1, 0)),
axis.text.x = element_text(size = 12, family = fontfamily1),
axis.text.y = element_text(size = 12, family = fontfamily1),
plot.caption = element_text(size = 10, family = fontfamily1, color = "darkgrey")) +
theme(plot.title = element_markdown(),
plot.subtitle = element_markdown(),
plot.caption = element_markdown(),
panel.grid.major.x = element_blank(),
panel.grid.minor.y = element_blank(),
legend.position="none")
dev.off()
# define font families for title, subtitel and annotations
fontfamily1 <- "Roboto"
fontfamily2 <- "Roboto Condensed"
df |> filter(Homosexuality == 10 | Homosexuality == 1) |>
pivot_longer(cols = c(Homosexuality)) |>
group_by(Year, value) |>
summarise(n = n()) |>
mutate(N = max(cumsum(n)), freq = n/N) |>
ggplot(aes(x = as_label(Year), y = freq, group = as_label(value), color = as_label(value))) +
scale_color_manual(values = c("#005c8b", "#E69F00")) +
geom_line(linewidth = 2) +
geom_point(size = 4) +
geom_point(size = 2, color = "white") +
scale_y_continuous(labels = scales::percent, limits = c(0,1)) +
labs(x = "", y = "") +
labs(title = "<b>Austrians have become more tolerant over time</b>") +
labs(subtitle = "Q: Please tell me whether you think homosexuality can <b><span style = 'color: #E69F00;'>always be justified</span></b>, <b><span style = 'color: #005c8b;'>never be justified</span></b> or something in between.") +
labs(caption = "Source: European Values Study 1990-2018; Austria Longitudinal Data") +
theme_minimal() +
theme(text = element_text(size = 14, family = fontfamily1),
title = element_text(size = 18, family = fontfamily1),
plot.title = element_text(size = 18, family = fontfamily1),
plot.subtitle = element_markdown(size = 14, family = fontfamily2, margin = ggplot2::margin(1, 0, 1, 0)),
axis.text.x = element_text(size = 12, family = fontfamily1),
axis.text.y = element_text(size = 12, family = fontfamily1),
plot.caption = element_text(size = 10, family = fontfamily1, color = "darkgrey")) +
theme(plot.title = element_markdown(),
plot.subtitle = element_markdown(),
panel.grid.major.x = element_blank(),
panel.grid.minor.y = element_blank(),
legend.position="none")
Infra4NextGen Webinar | 19 November 2024