0

I want to have an overalapping bar chart, with different colours for each section in a bar (Horizon), but all bars follow the same theme. For some reason pairs of bars are appearing different colours even though the horizon groups don't have these colours. This is what i've got so far. The Horizon values should follow the colours shown in the legend, not the pink, blue/green and orange bar themes.

RdataHor$Site <- as.character(RdataHor$Site)
RdataHor$Site <- factor(RdataHor$Site, levels=unique(RdataHor$Site))
Horizondata <- RdataHor
ggplot(data = Horizondata, aes(x = Site, y = Depth, fill = Horizon)) +
  geom_col(position = "identity", alpha = 0.3) + 
  scale_y_reverse()

enter image description here

Phil
  • 7,287
  • 3
  • 36
  • 66
  • 4
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Jul 20 '21 at 03:39
  • 1
    Since you are overlaying bar on top of one another, you are seeing the combined color. I think much better way to visualize this would be either stacked bar graphs or side-by-side bar graphs – monte Jul 20 '21 at 06:42
  • thanks @monte they are supposed to be depth layers so i would like to have them overlayed but only see the top colour. If i raise the alpha level they default to one colour. Is there a way to make a bar that extends say from y100 to 200 instead of overlaying them all starting at 0 – Ben Grier Jul 20 '21 at 11:08
  • Isn't that stacked bar graph? see for example: https://stackoverflow.com/questions/21236229/stacked-bar-chart – monte Jul 20 '21 at 14:27
  • @monte if i create it as a stacked bar graph then it adds the depths together, so instead of the deepest part being 200 like in this one, it ends up being like 400. I think i have a way around it though – Ben Grier Jul 21 '21 at 02:00

0 Answers0