0

Suppose I have 3 age groups: Infants, Adults and Elderly. In each group, I have 3 subjects. For each age group, I'm plotting a combined line plot:

p1 <- plot(infants$`8838`, type="l", col="blue", ylim = c(0, 0.90), xlim = c(0,3000))
       lines(infants$`9048`, typr = "l", col="red")
       lines(infants$`9108`, typr = "l", col="green")
p2 <- plot(adol$`8804`, type="l", col="blue", ylim = c(0, 0.90), xlim = c(0,3000))
    lines(adol$`12291`, typr = "l", col="red")
    lines(adol$`12623`, typr = "l", col="green")
p3 <- plot(old$`10341`, type="l", col="blue", ylim = c(0, 0.90), xlim = c(0,3000))
    lines(old$`10690`, typr = "l", col="red")
    lines(old$`10896`, typr = "l", col="green")

Now I need to combine all that three plots in one graph. Could anyone please help me find an answer?

Thanks in advance!

J_F
  • 9,956
  • 2
  • 31
  • 55
  • Please edit your question based on these [guidelines](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). (Opinion based) Maybe do it with `ggplot2`? It seems "easier" to use. – NelsonGon Mar 01 '20 at 14:53
  • 1
    Before all your commands, type `op <- par(mfrow=c(1,3))`. At the very end, type `par(op)`. Place all your plotting commands inside those two commands. If you want the 3 plots on top of each other, replace `c(1,3)` with `c(3,1)`. – Edward Mar 01 '20 at 14:56

1 Answers1

1

You can use par(mfrow = c(1, 3)) before any plot() command to section the display. After that each call to plot() will use a new section. See ?par for details.

Coy
  • 329
  • 1
  • 7