Keeping background colour when adding stripes (bargraph)

Hi, I apologize if this is an easy question I am not the best at coding in R. I have given my bars certain colours and I want to also add diagonal stripes to some of the bars however when I do this it takes the colours from the background and instead makes the diagonal stripes that colour.
I want to just have plain black strips on top of the colours - here is the code I am using, what is it I need to add to stop the colour form changing:

barplot(means,ylab="Heptosomatic index (%)",names.arg=c("EOD","LD","EV", "1", "14", "28", "63", "117"), col=cols, density=c(10,10,10,0,0,0,0,0 ))


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)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.