An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130103/4d3e36e3/attachment-0001.pl>
How to plot multiple datasets
4 messages · Bruce Kindseth, Rui Barradas, Sarah Goslee +1 more
Hello, You shuld provide a data example, but see if the following is what you are looking for. x <- 1:10 y1 <- rnorm(10) y2 <- rnorm(10) y3 <- rnorm(10) # One way plot(x, y1, ylim = range(c(y1, y2, y3))) points(x, y2, col = "red") points(x, y3, col = "blue") # Another way plot(x, y1, ylim = range(c(y1, y2, y3)), type = "l") lines(x, y2, col = "red") lines(x, y3, col = "blue") Hope this helps, Rui Barradas Em 03-01-2013 16:39, Bruce Kindseth escreveu:
Good Morning, I have 3 sets of data, all with the same horizontal axis but with varying vertical input. I want to plot all 3 sets on one x-y plot. I can get 3 linear regression plots and 3 polynomial regression plots on the same chart but I have not been able to get more than one set of input data on the same chart. Can you help me? Thank you for all that you do to provide R to the public. Bruce Kindseth Narragansett, RI [[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.
Hi Bruce, That really isn't enough for anyone to be able to answer your question. In the simplest possible reading, you need lines() or points(), but your mention of regression leads me to believe you might want something more complex. Why don't you take a look at http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example and figure out how to clarify your question? Sarah
On Thu, Jan 3, 2013 at 11:39 AM, Bruce Kindseth <bkindseth at cox.net> wrote:
Good Morning, I have 3 sets of data, all with the same horizontal axis but with varying vertical input. I want to plot all 3 sets on one x-y plot. I can get 3 linear regression plots and 3 polynomial regression plots on the same chart but I have not been able to get more than one set of input data on the same chart. Can you help me? Thank you for all that you do to provide R to the public. Bruce Kindseth Narragansett, RI
-- Sarah Goslee http://www.functionaldiversity.org
Or
matplot(x, cbind(y1, y2, y3), ylab="y", col=c("black", "red",
"blue"), pch=1) # symbols
matplot(x, cbind(y1, y2, y3), ylab="y", col=c("black", "red",
"blue"), type="l") # lines ---------------------------------------------- David L Carlson Associate Professor of Anthropology Texas A&M University College Station, TX 77843-4352
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of Rui Barradas Sent: Thursday, January 03, 2013 12:54 PM To: Bruce Kindseth Cc: r-help at r-project.org Subject: Re: [R] How to plot multiple datasets Hello, You shuld provide a data example, but see if the following is what you are looking for. x <- 1:10 y1 <- rnorm(10) y2 <- rnorm(10) y3 <- rnorm(10) # One way plot(x, y1, ylim = range(c(y1, y2, y3))) points(x, y2, col = "red") points(x, y3, col = "blue") # Another way plot(x, y1, ylim = range(c(y1, y2, y3)), type = "l") lines(x, y2, col = "red") lines(x, y3, col = "blue") Hope this helps, Rui Barradas Em 03-01-2013 16:39, Bruce Kindseth escreveu:
Good Morning, I have 3 sets of data, all with the same horizontal axis but with
varying
vertical input. I want to plot all 3 sets on one x-y plot. I can
get 3
linear regression plots and 3 polynomial regression plots on the same
chart
but I have not been able to get more than one set of input data on
the same
chart. Can you help me? Thank you for all that you do to provide R to the public. Bruce Kindseth Narragansett, RI [[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.
______________________________________________ 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.