One feature I find makes a really good dashboard is when the different elements are connected and fit well together. I remember one time seeing a dashboard with two graphs stacked on top of one another. The top was a line graph showing each country’s CO2 emissions by year over the last decade or so. The bottom one was a world map that shaded each country by its CO2 emissions in the most recent year in the data. What was really cool is that when you selected a line it would show the country name and data for that country and only highlight that country on the map. I think using interactivity to make two visualizations work together like this is a great way to make a cool and informing dashboard. Cramming as many graphs as you can onto a dashboard can be overwhelming for the reader so it is best to think about how the separate elements can work together to tell one story.
Put your reflection here
library(tidyverse)
library(plotly)
library(gghalves)
library(viridis)
df = read_csv("data/pgaTourData copy.csv")
df$money <- as.numeric(gsub("[$,]", "", df$Money))
Do the following:
geom_point()).df = df %>% rename(driving_distance = `Avg Distance`)
df <- df %>%
mutate(distance_quantile = cut(driving_distance,
breaks = quantile(driving_distance,
c(0, 0.25, 0.5, 0.75, 1),
na.rm = TRUE),
labels = c("0-25th", "26-50th", "50-75th",
"Over 75th")))
df2 = df %>%
drop_na()
plot1 = ggplot(df2, aes(x = distance_quantile, y = Points))+
geom_half_point(aes(color = distance_quantile), side = "l", size = 0.5) +
geom_half_violin(aes(fill = distance_quantile), side = "r")+
guides(color = "none", fill = "none") +
coord_flip()+
labs(title = "Distribution of Season Points by Driving Distance Bracket",
x = "Driving Distance Percentile",
y = "Season Points") +
theme_bw()+
scale_color_viridis(option = "cividis", discrete = T)+
scale_fill_viridis(option = "cividis", discrete = T)
plot1
plot2 = ggplot(df2, aes(x = distance_quantile, y = Points, text = Year))+
labs(title = "Distribution of Season Points by Driving Distance Bracket",
x = "Driving Distance Percentile",
y = "Season Points")+
geom_jitter(width = 0.2, height = 0, aes(color = distance_quantile), alpha = 0.7)+
guides(color = "none")+
scale_color_viridis(option = "A", discrete = T, begin = 0, end = .7)
plot2
ggplotly().ggplotly(plot2)
ggplotly(plot2, tooltip = "text")
df2 = df2 %>%
mutate(label = paste0( "Player: ", `Player Name`, "<br>",
"Year: ", Year,"<br>",
"Points: ", Points))
plot3 = ggplot(df2, aes(x = distance_quantile, y = Points, text = label))+
labs(title = "Distribution of Season Points by Driving Distance Bracket",
x = "Driving Distance Percentile",
y = "Season Points")+
geom_jitter(width = 0.2, height = 0, aes(color = distance_quantile), alpha = 0.7)+
guides(color = "none")+
scale_color_viridis(option = "A", discrete = T, begin = 0, end = .7)+
theme_bw()
ggplotly(plot3, tooltip = "label")