1

I can make a stacked bar plot just fine.

Reprex:

ggplot(filter(mpg, cyl == 4 | cyl ==6)) + 
  geom_bar(aes(x = class, fill = factor(cyl)), alpha = .3)

enter image description here

However, I would like for the the bars to be on top of each other, so you would see the colors mix, minivan for example should stay at a count of 10.

The bars also don't have to be completely on top of each other, bud def. not completely side to side, at least half or more.

Angel Cloudwalker
  • 2,015
  • 5
  • 32
  • 54
  • 3
    use `position` as in this question https://stackoverflow.com/q/60843077/2994949 – rawr Apr 06 '20 at 20:55
  • Indeed, @Tjebo, this is probably a duplicate question then but when I searched bar over bar in stackoverflow none of those came up! – Angel Cloudwalker Apr 06 '20 at 21:03
  • 1
    Don't worry! This is also what marking duplicates is for - it makes it more likely that people find an answer. Google has sometimes quite mysterious ways. In this case, I don't even remember what I used yesterday to find it. Sometimes, I think the best duplicate results come up when you are actually asking the questions - SO suggests a range of 'similar questions' and they are often pretty spot on – tjebo Apr 07 '20 at 06:53

0 Answers0