slope_plot <- data_for_plot |>
ggplot2:: ggplot (ggplot2:: aes (x = metric, y = value,
group = row_num)) +
ggplot2:: geom_line (ggplot2:: aes (color = color_line,
size = color_line)) +
ggplot2:: geom_point (ggplot2:: aes (color = color_line,
size = color_line)) +
ggplot2:: scale_color_manual (values = c ("games" = "lightpink" ,
"label-games" = "lightgreen" )) +
ggplot2:: scale_size_manual (values = c ("games" = 0.5 ,
"label-games" = 1.5 )) +
ggplot2:: scale_x_discrete (labels =
c ("pts_dif" = "Points Difference" ,
"raw_net_eff" = "Raw Net Efficiency" )) +
ggplot2:: labs (
title = "Are all 20-point \n wins the same?" ,
x = "" , y = "" ,
caption = "Data via barttorvik.com | Viz by Chris at Bless your chart | January 10, 2025"
) +
ggplot2:: scale_y_continuous (limits= c (15 , 40 )) +
theme_me () +
ggplot2:: theme (
legend.position = "none" ,
plot.title = ggtext:: element_markdown (family = "mono" ),
axis.text.y = ggplot2:: element_blank (),
axis.text.x = ggplot2:: element_blank (),
axis.title.x = ggplot2:: element_text (size = 14 , face = "bold" ),
plot.caption = ggtext:: element_markdown (family = "mono" )
) +
ggplot2:: annotate (
"text" ,
x = 1 ,
y = 17.5 ,
label = "Margin of \n Victory" ,
color = "#333333" ,
size = 4 ,
fontface = 'bold' ,
family = 'mono' ,
hjust = 0.5
) +
ggplot2:: annotate (
"text" ,
x = 2 ,
y = 17.5 ,
label = "Raw Net Efficiency \n per 100 possessions" ,
color = "#333333" ,
size = 4 ,
fontface = 'bold' ,
family = 'mono' ,
hjust = 0.5
) +
ggplot2:: annotate (
"text" ,
x = 0.94 ,
y = 20 ,
label = "+20" ,
color = "#333333" ,
size = 3.5 ,
fontface = 'bold' ,
family = 'mono' ,
hjust = 0.5
) +
ggplot2:: annotate (
"text" ,
x = 2.09 ,
y = 37.7 ,
label = "+37.7" ,
color = "#333333" ,
size = 3.5 ,
fontface = 'bold' ,
family = 'mono' ,
hjust = 0.5
) +
ggplot2:: annotate (
"text" ,
x = 2.09 ,
y = 29.7 ,
label = "+29.7" ,
color = "#333333" ,
size = 3.5 ,
fontface = 'bold' ,
family = 'mono' ,
hjust = 0.5
) +
ggplot2:: annotate (
"text" ,
x = 2.09 ,
y = 23.5 ,
label = "+23.5" ,
color = "#333333" ,
size = 3.5 ,
fontface = 'bold' ,
family = 'mono' ,
hjust = 0.5
) +
ggplot2:: annotate (
"label" ,
x = 2.39 ,
y = 37.7 ,
color = "#333333" ,
fill = "lightgreen" ,
size = 2.5 ,
fontface = 'bold' ,
family = 'mono' ,
alpha = .3 ,
hjust = 0.5 ,
label = "Houston 62, Troy 42 \n ~55 possessions"
) +
ggplot2:: annotate (
"label" ,
x = 2.39 ,
y = 29.7 ,
color = "#333333" ,
fill = "lightgreen" ,
size = 2.5 ,
fontface = 'bold' ,
family = 'mono' ,
alpha = .3 ,
hjust = 0.5 ,
label = "Texas A&M 80, Texas 60 \n ~68 possessions"
) +
ggplot2:: annotate (
"label" ,
x = 2.39 ,
y = 23.6 ,
color = "#333333" ,
fill = "lightgreen" ,
size = 2.5 ,
fontface = 'bold' ,
family = 'mono' ,
alpha = .3 ,
hjust = 0.5 ,
label = "Ohio St. 103, ISU 83 \n 79 possessions"
) +
ggplot2:: annotate (
geom = "curve" ,
color = "#333333" ,
x = 1.3 ,
y = 35 ,
xend = 1.5 ,
yend = 25 ,
curvature = - .6 ,
arrow = ggplot2:: arrow (length = ggplot2:: unit (2 , "mm" ), )
) +
ggplot2:: annotate (
"label" ,
x = 1.1 ,
y = 36.6 ,
color = "#333333" ,
fill = "lightpink" ,
size = 3 ,
fontface = 'bold' ,
family = 'mono' ,
alpha = .3 ,
hjust = 0.5 ,
label = "51 different games \n played at a different pace \n with different efficiencies"
)
ggplot2:: ggsave (
"slope_plot.png" ,
slope_plot ,
h = 8.25 ,
w = 8.25 ,
dpi = 600 ,
type = 'cairo'
)
slope_plot