0

I have to plot two continuous time series requiring separate scales for axis.

However, my code doesn't work:


ggplot()+
    geom_line(t, mapping = aes(y = EMBIG, x = Date), colour = "blue")+
    geom_line(t, mapping = aes(y = VIX, x = Date), colour = "red")+
    scale_y_continuous(name = "EMBIG", breaks = NULL,
                     sec.axis = dup_axis(name = "VIX"))

Do you have any suggestion? Also outside ggplot is a solution

Vitomir
  • 295
  • 2
  • 14
  • This popular post with the same question has good answers - do they address what you're looking for? [How can I plot with 2 different y-axes?](https://stackoverflow.com/questions/6142944/how-can-i-plot-with-2-different-y-axes) – phalteman May 09 '19 at 16:40
  • Another, specific to ggplot2 is [Plot with 2 y axes, one y axis on the left, and another y axis on the right](https://stackoverflow.com/questions/3099219/plot-with-2-y-axes-one-y-axis-on-the-left-and-another-y-axis-on-the-right). (With an answer from Hadley Wickham) – Jet May 09 '19 at 16:42

0 Answers0