How to Create a GGPlot Stacked Bar Chart - Datanovia Add labels. 4 steps required to compute the position of text labels: Group the data by the dose variable; Sort the data by dose and supp columns. As stacked plot reverse the group order, supp column should be sorted in descending order. Calculate the cumulative sum of len for each dose category. Used as the y coordinates of labels.