Djokovic vs Nadal Head-to-head
Data
This plot uses the rafa_novak data frame from the gcubed library. This data frame has one row for every match played between Novak Djokovic and Rafael Nadal over the course of their professional careers. In particular, the column Winner has the name of the winner of the match.
This data was sourced from the ATP’s Head2Head Comparison tool and was current as of 2019-08-15.
library(gcubed)
head(rafa_novak)
## # A tibble: 6 x 8
## Year Event Location Surface RND Winner Result Loser
## <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 2019 ATP Masters… Italy Outdoor … F Rafael … 60 46 61 Novak D…
## 2 2019 Australian … Australia Outdoor … F Novak D… 63 62 63 Rafael …
## 3 2018 Wimbledon Great Bri… Outdoor … SF Novak D… 64 36 76… Rafael …
## 4 2018 ATP Masters… Italy Outdoor … SF Rafael … 764 63 Novak D…
## 5 2017 ATP Masters… Spain Outdoor … SF Rafael … 62 64 Novak D…
## 6 2016 ATP Masters… Italy Outdoor … QF Novak D… 75 764 Rafael …
This data frame is already suitable for making the plot.
Code
library(ggplot2)
rafa_novak_plt <- ggplot(rafa_novak, aes(x = Surface, fill = Winner)) +
geom_bar(position = "dodge") +
ylab("Wins") +
ggtitle("Djokovic vs Nadal Head-to-Head") +
theme_bw() +
theme(panel.grid.major.x = element_blank(),
plot.title = element_text(size = 16, face = "bold", hjust = 0.5))
rafa_novak_plt