library(tidyverse)
library(ggthemes)
# load WNBA regular season stats data
<- read_csv("WNBAStats.csv")
WNBAStats
# create density plot
<- ggplot(WNBAStats, aes(Pp_3, col=TEAM)) +
p_3pt_den geom_density() +
xlab("3 Point Percentage") +
ylab("")+
labs(title="WNBA 3 Point Percentage for 2022 Season")
# adding minimal theme
<- p_3pt_den + theme_minimal()
p_3pt_den # adding facet_wrap to separate out density by team
<- p_3pt_den + facet_wrap(~TEAM,nrow=3)
p_3pt_den # removing legend
<- p_3pt_den + theme(legend.position = "none") p_3pt_den
STAA 566 ggplot
R Code
Save figure as pdf
pdf("WNBA3pt.pdf", heigh=6, width=8)
print(p_3pt_den)
dev.off()
quartz_off_screen
2
Display figure in HTML
p_3pt_den
I got data from the WNBA online stats webpage (https://stats.wnba.com/teams/boxscores-traditional/?Season=2022&SeasonType=Regular%20Season)