How to change the background colour of `fillstyle`?

With the StatsPlots package (not with Makie or other packages), I would like to change the background colour of fillstyle, where it has :+, :|, and etc. Is there any way? Alternatively, I wrote the following code which draw two overlapping bar graphs, but the problem is I cannot change the fillings in legend.

  using StatsPlots
  gr()
  
  bar_group = 1:3
  bar_data = [rand(3) rand(3) rand(3) rand(3) rand(3) rand(3) rand(3) rand(3) rand(3)]
  
  gb = groupedbar(bar_group, bar_data, bar_position =:stack, bar_width = 0.5, 
      label=[ "item1" "item2" "item3" "item4" "item5" "item6" "item7" "item8" "item9"],
      fillcolor=[:black :darkgray :lightgray :black :darkgray :lightgray :black :darkgray :lightgray])
  groupedbar!(bar_group, bar_data, bar_position =:stack, bar_width = 0.5, label=false,
      fillcolor=:black, fillalpha=0.5, fillstyle=[nothing nothing nothing :| :- :+ :/ :\ :x])
  
  plot!(legend=:outerbottom, legendcolumns=3, legend_font_halign=:right)

display(gb) 

By using the fill style first, then overlaying the grayscale background fill on top using a bit of alpha transparency, you can get something like this:

However, the background color won’t appear in the legend for the filled-style items.

1 Like

Thank Rafael for your suggestion. It is worth trying. I hope that in later version, the fillstyle has more optional arguments, like ( :/, linecolor, backcolor), so the legend items are also automatically updated.