I'm looking for ways to plot sequencing data like this:

It seems to be a common plot. I know there are ways to plot a table filled with colors from a relevant post
tableplot <- function(ret, nrow, ncol, main){
m <- matrix(as.integer(ret$y),nrow,ncol)
image(1:nrow,1:ncol,m,col=c("grey","green"),axes=FALSE, xlab="gene",ylab="sample",main=main)
text(row(m),col(m),labels=matrix(ret$x,nrow,ncol))
}
ret <- data.frame("x" = c("1-gene1","1-gene2","2-gene1","2-gene2"), "y" = c(1,1,0,1)) #0 is loss, 1 is gain.
tableplot(ret, 2, 2, "My tests")
I also found a similar question with the last answer geomSplitTile giving a plot on the right direction, but I failed to comprehend the code.