Skip to content

Instantly share code, notes, and snippets.

@cavedave
Created August 12, 2020 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cavedave/667b251e0c7aad4ac00687b6642c294a to your computer and use it in GitHub Desktop.
Save cavedave/667b251e0c7aad4ac00687b6642c294a to your computer and use it in GitHub Desktop.
Snooker breaks at world championship per year http://www.snooker.org/Plr/wc_centuries.shtml
breaks <- read.csv("breaks.csv", stringsAsFactors=FALSE)
breaks<-select (breaks,-c(X,X.1,X.2))
breaks<-na.omit(breaks)
names(breaks)[names(breaks) == "X."] <- "Centuries"
library(ggplot2)
# Basic scatter plot
g<-ggplot(breaks, aes(x=Year, y=Centuries)) +
geom_point(shape=1) + # Use hollow circles
geom_smooth(method=lm) +
ggtitle("Century Breaks at World Snooker Championships")+theme_web_bw()
g<- g+ annotate("text", x = 2017, y = 8, label = "Cor 0.93")
ggsave('snooker.png',width=10, height=7)
theme_web_bw <- function() {
theme_bw() + # note ggplot2 theme is used as a basis
theme(plot.title = element_text(size = 16, face = "bold",
hjust = .5,
margin = margin(t = 5, b = 25)),
plot.caption = element_text(size = 12, hjust = 0,
margin = margin(t = 15)),
panel.grid.major = element_line(colour = "grey88"),
panel.grid.minor = element_blank(),
legend.title = element_text(size = 14, face = "bold"),
legend.text = element_text(size = 14),
strip.text = element_text(size = 14, face = "bold"),
axis.text = element_text(size = 14),
axis.title.x = element_text(margin = margin(t = 10), size = 15),
axis.title.y = element_text(margin = margin(r = 10), size = 15))
}
cor(breaks$Year, breaks$Centuries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment