Keeping background colour when adding stripes (bargraph)

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers.

This one is nearly complete, but for means, the data itself. That makes it hard to see what needs to be changed.

The data doesn't have to be all the data, just enough to illustrate the issue. And it doesn't even have to be the same data. Any data in one of the standard datasets or a library specific dataset with the same effects will do.

Two ways to capture the data


and manually cut and paste into the reprex or just between beginning and ending triple backtick delimiters

Or you can use this function that I stole from someone without making a note who's to be credited and it will do copy to clipboard for you

#> Loading required package: clipr
#> Welcome to clipr. See ?write_clip for advisories on writing to the clipboard in R.
#> Loading required package: magrittr
#> Loading required package: stringr

specimen <- function(x)
  deparse(x) %>%
  str_c(collapse = '') %>%
  str_replace_all('\\s+', ' ') %>%
  str_replace_all('\\s*([^,\\()]+ =) (c\\()', '\n  \\1\n    \\2')  %>%
  str_replace_all('(,) (class =)', '\\1\n  \\2') %>%
  write_clip(allow_non_interactive = TRUE)