complex grouped bar charts

33 views
Skip to first unread message

lily li

unread,
Sep 16, 2017, 7:07:38 PM9/16/17
to ggp...@googlegroups.com
Hi ggplot users,

I'd like to ask that how to plot grouped bar charts with error bars. For the dataframe below, A, B, C belong to group 1, A2, B2, C2 belong to group 2, etc. In each figure, there are several such groups on x-axis. In each group, there are three bars, while each bar represents the median values in A, B, C, or A2, B2, C2, etc. In each group, bar A is in the y-direction, while bars B and C are in the negative y-direction. The error bars are also shown on each bar variable to summarize all the values from row1 to row10 for example.

Also, though A, and B & C are in the two directions, they share the same x-axis, so that the two directions on y-axis still show positive values, but different variables. I don't know how to present this on the y-axis label. Could anyone give me some hints on the figure? Thanks for your help.

I also attached a figure about bar charts, but in my case the second and third bars are in the opposite direction with the first bar in each group. I don't know how to do this, though it is possible to change the values in B and C, B2 and C2, etc, but the labels on y-axis may also change. Thanks.

        A  B  C    A2  B2  C2
1     65 21 54  64  23   55
2     66 23 55  66  22   54
3     54 24 56  70  25   60
4     44 23 53  68  19   49
5     67 22 52  60  18   48
6     66 21 50  54  20   46
7     45 20 51  55  21   51
8     56 19 57  58  22   54
9     40 25 58  59  18   52
10   39 24 53  61  21   48

grouped_bar.pdf

Hadley Wickham

unread,
Sep 17, 2017, 4:29:07 PM9/17/17
to lily li, ggp...@googlegroups.com
Also posted at https://community.rstudio.com/t/complex-grouped-bar-charts/815

We generally consider it somewhat inconsiderate to post the same
question in multiple places - someone might spend their time answering
it here when it has already be answered elsewhere.

Hadley
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
http://hadley.nz

lily li

unread,
Sep 17, 2017, 4:33:07 PM9/17/17
to Hadley Wickham, ggp...@googlegroups.com
Hi Hadley,

Yes, I just posted it on the Rstudio community. I didn't hear back here, and thought people all moved to the new community website. Sorry about that, thanks.

> To unsubscribe: email ggplot2+unsubscribe@googlegroups.com

> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
Reply all
Reply to author
Forward
0 new messages