Edit: I managed to change the plot to my preferences. Thanks to anyone who wanted to help!
I have following problem:
For a publication I need to create bar graph in black and white including patterns.
I've tried a lot of different ways, but for me the best way was actually to use geom_col_pattern.
My syntax looks like this:
A.1 <- ASC[ 2:9, ]
colnames(A.1) <- ASC[ 1,]
A.1$ASC <- as.numeric(A.1$ASC)
ggplot(A.1, aes(x = sex, y = ASC, fill = interaction(time, treatm))) +
position = position_dodge(width = 0.8),
width = 0.7,
fill = c("white", "white", "grey", "grey", "white", "white", "grey", "grey"),
colour = "black",
aes(pattern = interaction(time, treatm),
pattern_angle = interaction(time, treatm),
pattern_spacing = interaction(time, treatm)),
pattern = c("none", "stripe", "none", "stripe", "none", "stripe", "none", "stripe"),
pattern_density = 0.02,
pattern_fill = "black",
pattern_colour = "black",
pattern_spacing = 0.01)
For dataset ASC I used following table via Excel:
sex | time | treatm | ASC
female | LPA_1 | Contr | -20
female | LPA_1 | PO | -10
female | LPA_2 | Contr | -19
female | LPA_2 | PO | 1
male | LPA_1 | Contr | -28
male | LPA_1 | PO | -5
male | LPA_2 | Contr | -18
male | LPA_2 | PO | -9
And got this graph:
My question is now:
Is it possible for the two striped bars to have the same pattern (so they have the same pattern but different coulour)?
I tried changing it by changing pattern_angle, however the patterns didn't change but the bars got stacked upon each other, which won't work for me.
Also the patterns in the legend don't match the patterns in the garph, do you maybe also know how to change that?
Does anybody know how to solve this problem? Or do you maybe know another way for me to get the result I need?
Thanks in advance!