[R] ggplot2 bar chart: order display for each group

Kai Yang y@ngk@|9999 @end|ng |rom y@hoo@com
Mon Sep 20 23:07:33 CEST 2021


Hello List,
I submitted the code below, it will show two groups of avg_time bar chart for each gc_label and got the plot.

ggplot(s8_GCtime, aes(fill=GTresult, y=avg_time, x=gc_label, label = avg_time)) + 
  geom_bar(position=position_dodge(), stat="identity") +
  geom_text(aes(label=avg_time), vjust=1.6, position = position_dodge(0.9), size=3.5)+
  theme(axis.text.x = element_text(angle = 45))



I found the ggplot put all of small number of avg_time on left side, bigger number of avg_time on right side for each gc_label. But I hope to use order by GTresult (see the plot I attached, I want to put all of blue in right and orange in left side, but Amber and Nadyah are not in that order). Could you tell me how to do this?

Thanks,
Kai


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1632171629110blob.jpg
Type: image/png
Size: 304695 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20210920/44941351/attachment.png>


More information about the R-help mailing list