There are 4 groups of 3 bars on my horizontal bar chart. I would like the top two groups (ie top 6 bars) to have the colour wheat 1 as their background and the bottom two groups (ie the bottom 6 bars) to have the background colour wheat 2. Please look at the link below to see what I have so far.
I have four regions of space Far left space (LS), central left space (LS-C), central right space (RS-C) and far right space (RS). I have three conditions A, B, C. Combined this means I have 12 conditions
My data resembles this fakedata
:
condition <- c( "LS-A", "LS-B","LS-C", "LS-C-A", "LS-C-B", "LS-C-C",
"RS-C-A", "RS-C-B", "RS-C-C", "RS-A", "RS-B", "RS-C")
as.factor(condition )
condition <- factor(condition,
levels = c("LS-A","LS-B","LS-C","LS-C-A","LS-C-B","LS-C-C", "RS-C-A","RS-C-B","RS-C-C", "RS-A","RS-B", "RS-C"))
#put them in the order I Want to appear on the graph
region <- c("Far-right", "Far-right", "Far-right", "RC", "RC", "RC", "LC", "LC", "LC", "Far-left", "Far-left", "Far-left")
as.factor(region)
region <-factor(region,
levels = c("Far-right", "RC", "LC", "Far-left"))
mean <- c(-2, -1, 2, -3, 4, 2, -4, 2, 4, 2, 4, 1)
fakedata <- data.frame(condition, region, mean)
here is the code I have so far
# 1: horizontal barplot
p <- ggplot(fakedata, aes(x=region, y = mean, fill= condition )) +
geom_bar(width=.6, position = position_dodge(width=0.6), stat = "identity", color = "black", size = 0.3) +
coord_flip(ylim = c(-5, 5))
p <- p + scale_fill_manual(values=c("yellow", "green1", "royalblue", "yellow", "green", "blue", "yellow", "green", "blue","yellow", "green", "blue"))
p <- p + theme(legend.position = "none")
p <- p + theme_bw() + theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.line = element_line(colour = "black"), legend.position = "none")
p <- p + theme (panel.background = element_rect(linetype= "solid", color = "black", fill=NA, size = 0.5))
p <- p + geom_abline(mapping = NULL, intercept = 0, slope= 0, color = "black", size= 0.25, show.legend = NA)