about plot in r

36 views
Skip to first unread message

lily li

unread,
Nov 1, 2015, 6:54:56 PM11/1/15
to ggp...@googlegroups.com
I want to ask that how to draw a plot with two different y-axis but one x-axis? For example, one y-axis represent one parameter, from bottom to top the lowest to highest, while another y-axis represent another parameter, from top to bottom the lowest to highest. Thanks for your help.

Ben Bolker

unread,
Nov 1, 2015, 9:00:31 PM11/1/15
to lily li, ggp...@googlegroups.com
http://stackoverflow.com/questions/22701606/how-to-plot-bars-and-one-line-on-two-y-axes-in-the-same-chart-with-r-ggplot

and other questions on StackOverflow.

It's not easy to do in ggplot2, because two-axis plots are somewhere
between not recommended and frowned upon in this particular part of
the statistical/quantitative graphics community ...
> --
> --
> 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.

Felix Lankester

unread,
Nov 2, 2015, 3:32:26 AM11/2/15
to Ben Bolker, lily li, ggp...@googlegroups.com
It is possible, but you will need to use base R graphics to do this.

Brian

unread,
Nov 2, 2015, 4:25:45 AM11/2/15
to Ben Bolker, lily li, ggp...@googlegroups.com
I second that.

another example:

https://rpubs.com/kohske/dual_axis_in_ggplot2

Konstantinos L. Papageorgiou

unread,
Nov 2, 2015, 4:44:37 AM11/2/15
to ggp...@googlegroups.com
note the top comment :)
--
Konstantinos L. Papageorgiou
mail: k...@eworx.gr

EWORX S.A.
66 Jean Moreas St
Athens 15231 - Greece
t: +30 210 614 8380
f: +30 210 614 8381
web: www.eworx.gr

lily li

unread,
Nov 2, 2015, 11:48:54 PM11/2/15
to Konstantinos L. Papageorgiou, ggp...@googlegroups.com
Thanks all for your reply. I also want to know how to make the second y-axis reversed? i.e., from top to bottom is increasing, rather than from bottom to top increasing. Thanks very much.
Reply all
Reply to author
Forward
0 new messages