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

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Tue Sep 21 01:43:00 CEST 2021


I could, but this question is off topic on this mailing list. Read the Posting Guide before you post again. Help for ggplot2 can be found in many places... start your search here https://cran.r-project.org/web/packages/ggplot2/index.html.

(Hint: your data should be a factor.)

On September 20, 2021 2:21:51 PM PDT, Kai Yang via R-help <r-help using r-project.org> wrote:
>Hello List,
>
>I submitted the code below, it will show two groups of avg_time bar chart for each gc_label.
>
>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 value of avg_time on left side, bigger value of avg_time on right side for each gc_label. But I hope to control the order by GTresult. Could you tell me how to do this?
>
>Thanks,
>Kai
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-help mailing list