I have a dataframe of football matches in la liga and I want to make a table where each row and column is a team name and each tile shows what the result was in the game between the two teams of row and column
I've tried many using geom_tile
and ggplot2
in many different ways but the closest I've come to is the below code
library(dplyr)
library(engsoccerdata)
spain = as.data.frame(spain)
library(ggplot2)
game1 = filter(spain, Season == "2012")
ggplot(game1, aes(home, reorder(visitor,desc(visitor)), fill = FT)) +
geom_tile(color="white", size=1.5, stat="identity", height=1, width=1) +
scale_fill_brewer(palette = rep(c("blue","white"),30)) +
geom_text(data=game1, aes(home, visitor, label = FT), size=rel(3)) +
scale_x_discrete(position="top") + scale_y_discrete(expand = c(0, 0)) +
xlab("Home") + ylab("Visitor") +
ggtitle("Laliga 2012")
I need the rows to be colored by oddity (odd rows white and even rows blue) Also I want the team names to be inside tiles over all I want my table to look like the first photo here but with striped lines
can anyone help me on modifications to my code?