1 year ago
#90268
Yerma Pareja Sanchez
geom_bar multiple criteria to sort and color
I have a data.table that Im plotting with geom_bar. The data.table has multiple pieces of information (aa, codon, pos) by which the counts (value/contig) can be grouped. For now, Im plotting contig (y) at each pos (x) by aa_codon. rn aa codon pos variable value contig 1: ASP_GAT_-17 ASP GAT -17 PC3 0.33962840 0.33962840 2: ASP_GAC_-17 ASP GAC -17 PC3 0.29253629 0.29253629 3: SER_TCT_-17 SER TCT -17 PC3 0.27009135 0.27009135
I managed to sort x by the position and the stacked bar by using fill according to which codon-pos is higher. However, each aa_codon_pos appears in one color and I would like that the color was by aa (keeping the same order). Every attempt to fill them by aa results in incorrect order of the stacked bar (since it summarizes all the codon_pos for that aa). Is there any way to sort and color the stacked bars independently?
ggplot2
geom-bar
stackedbarseries
0 Answers
Your Answer