library(ggplot2)
players <- c('Joel Embiid', 'Luka Dončić', 'Giannis Antetokounmpo',
'Shai Gilgeous-Alexander', 'Jalen Brunson', 'Devin Booker',
'Kevin Durant', 'Jayson Tatum', "De'Aaron Fox", 'Donovan Mitchell')
ppg <- c(34.7, 33.9, 30.4, 30.1, 28.7, 27.1, 27.1, 26.9, 26.6, 26.6)
data <- data.frame(players, ppg)
ggplot(data, aes(x = reorder(players, -ppg), y = ppg, fill = players)) +
geom_bar(stat = "identity", color = "black") +
labs(title = "Top 10 NBA Scorers by Average Points Per Game (2023-24 Season)",
x = "Players", y = "Average Points Per Game (PPG)") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
# Line Chart
ggplot(data, aes(x = reorder(players, -ppg), y = ppg, group = 1)) +
geom_line(color = "green", size = 1) +
geom_point(color = "red", size = 3) +
labs(title = "Average Points Per Game of Top 10 NBA Scorers (2023-24 Season)",
x = "Players", y = "Average Points Per Game (PPG)") +
theme_minimal() +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
# Load library for creating pie charts
library(ggplot2)
data$percentage <- round((data$ppg / sum(data$ppg)) * 100, 1)
ggplot(data, aes(x = "", y = percentage, fill = players)) +
geom_bar(stat = "identity", width = 1, color = "black") +
coord_polar("y", start = 0) +
labs(title = "Proportion of Total Points Contributed by Top 10 NBA Scorers (2023-24 Season)") +
theme_void() +
geom_text(aes(label = paste0(percentage, "%")),
position = position_stack(vjust = 0.5)) +
theme(legend.title = element_blank())