I don’t even know the name of this plot and what kind of data is required to make this, so sorry I don’t really have a minimal reproducible sample. with x axis the time and y axis all the variables,in each period each variable can be selected or not selected, indicated by the blue colour.
this plot is from Freyberger, Joachim, Andreas Neuhierl, and Michael Weber. "Dissecting characteristics nonparametrically." The Review of Financial Studies 33.5 (2020): 2326-2377.
>Solution :
You could use ggplot.
First we’ll create some plausible sample data:
set.seed(1)
df <- data.frame(on_off = c(replicate(26, cumsum(rnorm(20)))) > 3,
year = rep(2001:2020, 26),
factor = rep(LETTERS, each = 20))
And the plotting code is something like this:
library(ggplot2)
ggplot(df, aes(year, factor, fill = on_off)) +
geom_tile() +
scale_fill_manual(values = c('TRUE' = 'blue2', 'FALSE' = 'white')) +
theme_classic() +
theme(legend.position = 'none')

