0

I have two time series. One shows the number of interactions with advertisements and the other shows revenue. It's all generated data that I'm using to get a better understanding at this stuff.

I figured out how to layer the two charts on top of each other.

actions_ma <- ma(ts(actions_per_day_full$actions, start = c(2014, 1), frequency = 365), order = 15) 
rev_ma <- ma(ts(daily_rev_full$revenue, start = c(2014, 1), frequency = 365), order = 15)
autoplot(actions_ma) + autolayer(rev_ma)

two time series layered on top of each other

Is it possible to get them to have separate y axis so that you can see their relationship at different scales?

M--
  • 25,431
  • 8
  • 61
  • 93
goollan
  • 765
  • 8
  • 19
  • Having two y-axes is something `ggplot2` long argued against and fought, stating that two different scales can easily be mis-interpreted. I don't disagree but have found times when the confusion can be avoided/mitigated. Look into `ggplot2::sec_axis`, where you need to define a linear formula to map from one axis to the other. – r2evans May 27 '19 at 18:52
  • @r2evans dupe hammer? – M-- May 27 '19 at 19:54
  • 1
    goollan, I'm going to close this as a duplicate. (If I'm wrong, please comment and vote to re-open, I'll weigh in.) Heads up: one downvote (not me) is possibly because your question does not include sample data for reproducibility, or perhaps somebody feels you did insufficient research, idk. Either way, read down on the "duplicate" past the first/accepted answer (which says "just don't"), and on to those that actually show workable solutions (including those with `sec_axis`). @M-M, not sure if I should laugh or shake my head at the premise of *"dupe hammer"*. – r2evans May 27 '19 at 19:59
  • BTW: if the other q/a is not an appropriate answer for this, then it would be useful in addition to including sample data to have a plot where it actually shows two "things" ... this one appears to show only one, `rev_ma`, so it's confusing what purpose a second axis would serve. – r2evans May 27 '19 at 20:11

0 Answers0