Hatched fill with Plots and GR

I am working with a grouped bar graph with plots (and statsplots for the groupedbar() type) using GR as the backend. Here is an example of the type of graph I’m working with:

using Plots
using StatsPlots
using Colors

m = 4
n = 2

data = rand(n,m)
legend = ["this" "that" "the other" "those"]
fillcolor = [:green :blue :lightgreen :lightblue]
xcats = collect(1:n)

plt = groupedbar(data, xticks=(1:n, xcats), bar_position=:stack,
        bar_width=0.7,
        fill=(0,fillcolor),
        xlabel="x axis",
        ylabel="y axis",
        formatter=:plain,
        label=legend,
        legend=true)

This issue I am having is that I would like to be able to use a hatched fill on some of the stacked bars. In the example, say I would like to have hatched fill for “the other” and “those” categories, but a solid fill for “this” and “that.”

I have been reading through the plots documentation, the statsplots documentation, and the GR documentation. As best as I can tell, GR has the capability, but there isn’t an obvious plots option to get hatched fills.

Would anyone know how to do this?

Thank you.

2 Likes

I was also looking for this feature! I opened a (very first-stabby) pull request on Plots.jl implementing hatched fill in GR and PyPlot.

6 Likes

Thanks for taking the initiative to add this feature!

Thanks! Do you know if this is also implemented in the Plotly backend in Plots.jl somehow?

BeautifulMakie has this feature! Stripped barplots - Beautiful Makie