This week’s instruction was the first time I started to feel overwhelmed with the amount of possible visualizations that can be utilized to share data and whatever story I am trying to convey of that data. I want to master each and every visualization task we’re being taught in this class, and learning about the plethora of ways we can create interactivity through plotly, flexdashboards, Shiny, and so many more, it’s hard to know what to focus on, which to spend time using and learning, and how to develop more proficiency with whichever tool resonates with me.
Yes, explorable explanations have their place in enhancing the story we’re telling with our data. Interactivity allows for the audience to take more control of how they interact with the data, which can increase their connection to the data, and thus perhpas make the data more real to them. For example, the NY Times created an interactive exploration that shows the political bubble you live in. When I messed around with this explorable explanation, I found great connection to the data and narratives that permeate the media about regional similarities and differences in ideology. I could verify with data what I thought to be true based on perception and observation - this helped me speak more accurately, which improves the truthfulness of conversation.
library(tidyverse)
library(plotly)
library(scales)
library(htmlwidgets)
wnba <- read_csv("wnba-player-stats.csv")
wnba_2014 <- wnba %>%
drop_na(Pos) %>%
select(Player, year_ID, Pos, PER, Wins_Generated) %>%
filter(year_ID == "2014") %>%
filter(Pos %in% c("C","F","G")) %>%
mutate(fancy_label = paste0(Player, "<br>",
PER,
" player efficiency rating"))
head(wnba_2014)
## # A tibble: 6 x 6
## Player year_ID Pos PER Wins_Generated fancy_label
## <chr> <dbl> <chr> <dbl> <dbl> <chr>
## 1 Sancho Lyt… 2014 F 18.7 4.02 Sancho Lyttle<br>18.7 player e…
## 2 Tiffany Ha… 2014 G 17.8 3.92 Tiffany Hayes<br>17.8 player e…
## 3 Shoni Schi… 2014 G 12.2 1.18 Shoni Schimmel<br>12.2 player …
## 4 Jasmine Th… 2014 G 6.7 0.39 Jasmine Thomas<br>6.7 player e…
## 5 Celine Dum… 2014 G 8.4 0.53 Celine Dumerc<br>8.4 player ef…
## 6 Matee Ajav… 2014 G 3.3 -0.05 Matee Ajavon<br>3.3 player eff…
Do the following:
geom_point()).wnba_static <- ggplot(wnba_2014, mapping = aes(x = PER, y = Wins_Generated,
colour = factor(Pos))) +
geom_point(alpha = .7, size = 3) +
theme_minimal(base_family = "Roboto Condensed", base_size = 12) +
labs(title = "WNBA Player Efficiency Rating and Wins Generated",
subtitle = "2019 Season",
caption = "Source: Basketball-Reference.com",
x = "Player Efficiency Rating",
y = "Wins Generated") +
scale_color_viridis_d(breaks=c("F","C","G"),
name = "Position",
labels = c("Forward","Center","Guard"),
option = "plasma",
end = 0.9) +
theme(panel.grid.minor = element_blank(),
plot.title = element_text(face = "bold", size = rel(1.7)),
plot.subtitle = element_text(face = "plain", size = rel(1.3), color = "grey70"),
plot.caption = element_text(face = "italic", size = rel(0.7),
color = "grey70", hjust = 0),
legend.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
axis.title.x = element_text(margin = margin(t = 10), hjust = 0),
axis.title.y = element_text(margin = margin(r = 10), hjust = 1))
wnba_static
ggplotly().wnba_tooltip <- ggplot(wnba_2014, mapping = aes(x = PER, y = Wins_Generated,
colour = factor(Pos))) +
geom_point(aes(text = fancy_label),
alpha = .7, size = 3) +
theme_minimal(base_family = "Roboto Condensed", base_size = 12) +
labs(title = "WNBA Player Efficiency Rating and Wins Generated",
subtitle = "2019 Season",
caption = "Source: Basketball-Reference.com",
x = "Player Efficiency Rating",
y = "Wins Generated") +
scale_color_viridis_d(breaks=c("F","C","G"),
name = "Position",
labels = c("Forward","Center","Guard"),
option = "plasma",
end = 0.9) +
theme(panel.grid.minor = element_blank(),
plot.title = element_text(face = "bold", size = rel(1.7)),
plot.subtitle = element_text(face = "plain", size = rel(1.3), color = "grey70"),
plot.caption = element_text(face = "italic", size = rel(0.7),
color = "grey70", hjust = 0),
legend.title = element_text(face = "bold"),
axis.title = element_text(face = "bold"),
axis.title.x = element_text(margin = margin(t = 10), hjust = 0),
axis.title.y = element_text(margin = margin(r = 10), hjust = 1))
## Warning: Ignoring unknown aesthetics: text
ggplotly(wnba_tooltip, tooltip = "text")
interactive_plot <- wnba_tooltip
htmlwidgets::saveWidget(interactive_plot, "wnba_plot.html")
Good luck and have fun!