0

As we can see in this graph (full graph here):

enter image description here

There are two variables, the lighter orange bar shows the total value and another one is showing the partial variable. How can I organize those two bars together? (not 'stack', because I want both bars to start from the bottom)

ggplot(bad_drivers2, aes(State, nums)) + 
geom_bar(stat = "identity", fill= "royalblue") + 
coord_flip()
ggplot(bad_drivers2, aes(State, not_distracted_num)) + 
geom_bar(stat = "identity", fill= "blue") + 
coord_flip()
tjebo
  • 21,977
  • 7
  • 58
  • 94
Alex Yao
  • 99
  • 1
  • 7
  • Try adding a second `geom_bar` layer to the same plot but with a different `y` aesthetic. Like `+ geom_col( aes(y = not_distracted), fill = "blue")` – aosmith Jun 07 '18 at 17:52
  • @aosmith Thank you, it works, but the color "blue' never show up, it's showing red color all the time, and the legend is also weird.(how can I show the plot to you in comments?) – Alex Yao Jun 07 '18 at 18:02
  • upload the image somewhere and edit the question to reflect what you have now tried. ideally with some sample data to illustrate – Calum You Jun 07 '18 at 18:06
  • https://drive.google.com/drive/u/0/search?q=type:image, hope this works – Alex Yao Jun 07 '18 at 18:08
  • 3
    At the moment you are not adding a legend in your code (as long as `fill` is outside of `aes()`. It will help people help you if you add a reproducible example. See [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for some tips on how to do that. – aosmith Jun 07 '18 at 18:09
  • It was my fault, I put fill in aes(), now it has been solved. Thank you and have a good day – Alex Yao Jun 07 '18 at 18:12

0 Answers0