Before drawing a grouped barplot, you need to know how to draw a basic barplot with ggplot2. Then, the method is almost the same, except you add a “fill” argument in the aestetic, which cut your bar following the levels of a discrete variable. Bars can be one beside each other (“Grouped barplot“), one on top of each other (“Stacked barplot“) and showing percentage of each level (“Percent stacked barplot“).

It is easy to custom colors as described in the basic barplot section. Note that using faceting can be a good alternative to grouped barchart that are hard to read when to many groups.


Not what you are looking for ? Make a new search !

[mediatagger]

 


1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
AleBite Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
AleBite
Guest
AleBite

Hi,

is it possible to set the colour based on species instead of condition? I’d like to have the same colour for all banana, another one for all sorgho and so on.

Thanks