How to create a stacked bar graph with patterns rather than colors

hi,I want to create a stacked bar graph which has textures as fill(e.g diagonal lines,circles etc).
Most suggestions on stackover flow involves creating very long functions.
Is there a way to do this in a simpler way and within ggplot package

Try this:

1 Like

thanks martin but options provided here do not include stacked bar graphs

library(tidyverse)
library(ggpattern)

# create a dataset
specie <- c(rep("sorgho" , 3) , rep("poacee" , 3) , rep("banana" , 3) , rep("triticum" , 3) )
condition <- rep(c("normal" , "stress" , "Nitrogen") , 4)
value <- abs(rnorm(12 , 0 , 15))
data <- data.frame(specie,condition,value)

# Grouped
ggplot(data, aes(fill=condition, y=value, x=specie)) + 
  geom_bar_pattern(position="stack",stat="identity",
                   mapping=aes(pattern=condition))

image

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.