gina patel
2009-Feb-09 21:43 UTC
[R] How to plot multiple graphs each with multiple y variables
I am new to R and have a problem that I haven't been able to find the answer to in the guides or online. I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, and I would like to produce two plots side by side using mfrow. The first plot should contain data from D1-D4, the second should contain D5-D8. I can plot these separately using the code, par(mfrow=c(1,1)) plot(c(0.000001,1),c(0,100),type="n", xlab="D", ylab="% R", log="x") points(D1$L0,D1$K1_R1,lwd=2, col="blue", ) points(D2$L0,D2$K1_R2,lwd=2, col="red", ) points(D3$L0,D3$K1_Rt3,lwd=2, col="orange", ) points(D4$L0,D4$K1_R4,lwd=2, col="black", ) or par(mfrow=c(1,1)) plot(c(0.000001,1),c(0,100),type="n", xlab="D", ylab="% R", log="x") points(D5$L0,D1$K2_R1,lwd=2, col="blue", ) points(D6$L0,D2$K2_R2,lwd=2, col="red", ) points(D7$L0,D3$K2_Rt3,lwd=2, col="orange", ) points(D8$L0,D4$K2_R4,lwd=2, col="black", ) but how can I plot them together? Thanks in advance for your help, I appreciate any help you can give. [[alternative HTML version deleted]]
Gabor Grothendieck
2009-Feb-09 21:53 UTC
[R] How to plot multiple graphs each with multiple y variables
Try something like this where we use the built in data frame anscombe: opar <- par(mfrow = c(1, 2), no.readonly = TRUE) matplot(1:11, anscombe[1:4], pch = 1:4, col = 1:4, log = "x", ylab = "Y") matplot(1:11, anscombe[5:8], pch = 1:4, col = 1:4, log = "x", ylab = "Y") par(opar) On Mon, Feb 9, 2009 at 4:43 PM, gina patel <ginapatel1981 at yahoo.com> wrote:> I am new to R and have a problem that I haven't been able to find the answer to in the guides or online. > > I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, and I would like to produce two plots side by side using mfrow. The first plot should contain data from D1-D4, the second should contain D5-D8. > > I can plot these separately using the code, > > par(mfrow=c(1,1)) > plot(c(0.000001,1),c(0,100),type="n", xlab="D", ylab="% R", log="x") > points(D1$L0,D1$K1_R1,lwd=2, col="blue", ) > points(D2$L0,D2$K1_R2,lwd=2, col="red", ) > points(D3$L0,D3$K1_Rt3,lwd=2, col="orange", ) > points(D4$L0,D4$K1_R4,lwd=2, col="black", ) > > or > > par(mfrow=c(1,1)) > plot(c(0.000001,1),c(0,100),type="n", xlab="D", ylab="% R", log="x") > points(D5$L0,D1$K2_R1,lwd=2, col="blue", ) > points(D6$L0,D2$K2_R2,lwd=2, col="red", ) > points(D7$L0,D3$K2_Rt3,lwd=2, col="orange", ) > points(D8$L0,D4$K2_R4,lwd=2, col="black", ) > > but how can I plot them together? > > Thanks in advance for your help, I appreciate any help you can give. > > > > > > [[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >
Peter Alspach
2009-Feb-09 21:55 UTC
[R] How to plot multiple graphs each with multiple y variables
Kia ora Gina If I understand you correctly, you need to specify mfrow argument as c(1,2) and then make your two calls to plot(). HTH ... Peter Alspach> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of gina patel > Sent: Tuesday, 10 February 2009 10:43 a.m. > To: r-help at r-project.org > Subject: [R] How to plot multiple graphs each with multiple y > variables > > I am new to R and have a problem that I haven't been able to > find the answer to in the guides or online. > > I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, > and I would like to produce two plots side by side using > mfrow.? The first plot should contain data from D1-D4, the > second should contain D5-D8. > > I can plot these separately using the code, > > par(mfrow=c(1,1)) > plot(c(0.000001,1),c(0,100),type="n", xlab="D", ylab="% R", log="x") > ???? points(D1$L0,D1$K1_R1,lwd=2, col="blue", ) > ???? points(D2$L0,D2$K1_R2,lwd=2, col="red", ) > ???? points(D3$L0,D3$K1_Rt3,lwd=2, col="orange", ) > ???? points(D4$L0,D4$K1_R4,lwd=2, col="black", ) > > or > > par(mfrow=c(1,1)) > plot(c(0.000001,1),c(0,100),type="n", xlab="D", ylab="% R", log="x") > ???? points(D5$L0,D1$K2_R1,lwd=2, col="blue", ) > ???? points(D6$L0,D2$K2_R2,lwd=2, col="red", ) > ???? points(D7$L0,D3$K2_Rt3,lwd=2, col="orange", ) > ???? points(D8$L0,D4$K2_R4,lwd=2, col="black", ) > > but how can I plot them together? > > Thanks in advance for your help, I appreciate any help you can give. > > > > > > [[alternative HTML version deleted]] > > >The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited.