Hey folks,
I am looking for a way to combine two plots. Using ggarrange I have already been able to put them in one figure, but now I would like to combine them with two Y-axis. Unfortunately, I am not getting anywhere at the moment. R is still completely new territory for me. There are some explanations on the internet but unfortunately I have problems applying them to my specific data set. I am honest.
In Case anybody is interested: The upper graph symbolises the moon phase. 1 is full moon and 0 is new moon. The lower graph with geom_col() symbolises animals photographed by a camera trap. The goal is to determine the activity as a function of the moon phase.
The code I used for the two plots is:
Unless you have a very pressing reason to use a 2-y-axis graph with non-equivalent y-axes, the best advice at the moment is "Don't do it".
For some comments on this see:
My impression is that your currant 2-panel figure is much better.
This is a summary and the structure of my data. It is a table with camera trap data from several locations. I used "d1" for a single camera from that list.
The majority of people from statistical backgrounds will disagree with you on that. Dual y axis plots only make sense when there is a one-to-one transformation between the axes, e.g. to display two currencies or degrees Celsius/Fahrenheit (assuming there is ever a use case for this).
Your options are thus to conceive a way to transform the axes as specified in the link provided by andresrcs or to hack the building blocks of ggplot2 to do so. Both can be done (the former is much easier), but I would again advise you against it.
This is not in a copy/paste friendly format, which makes helping you harder. Can you please read the guide on the link I gave you and try to provide a proper reproducible example?