1
votes

I am trying to come up with a way to plot the following graph in R. I have looked up a lot but did not find a solution.
enter image description here

This is an example of how data are: df<-data.frame(matrix(NA,nrow=20,ncol=3)) colnames(df)<-c("time","A","B") df$time<-1:20 df$A<-c(rep("Success",3),rep("Fail",5),rep("Success",9),rep("Fail",3)) df$B<-c(rep("Success",7),rep("Fail",2),rep("Success",4),rep("Fail",7))

Any help to create the plot in R would be greatly appreciated.

1

1 Answers

2
votes

This approach can be useful:

library(dplyr)
library(ggplot2)
#Code
df %>% pivot_longer(-time) %>%
  ggplot(aes(x=time,y=name,fill=value))+
  geom_tile()

Output:

enter image description here