Hi, How could I plot two vectors on the same graph? For example, if I have two lists of results, each list is a vector. I want to display them on the same graph, so I can compare them. How could I do that? Regards, Justin
Justin - If both vectors are the same length, and the interpretations given to successive elements of each are the same, you might wish to make a bivariate scatterplot: plot(result.1, result.2). Otherwise, you could plot the values in each vector against their element numbers: plot(result.1, pch=15) points(result.2, pch=18) Depends on what makes sense in your own context. - tom blackwell - u michigan medical school - ann arbor - On Tue, 17 Feb 2004, Justin Xi ZHU wrote:> Hi, > > How could I plot two vectors on the same graph? For example, if I have two > lists of results, each list is a vector. I want to display them on the same > graph, so I can compare them. How could I do that? > > Regards, Justin > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Justin Xi ZHU > Sent: Tuesday, February 17, 2004 11:10 AM > To: r-help at stat.math.ethz.ch > Subject: [R] plot > > > Hi, > > How could I plot two vectors on the same graph? For example, > if I have two > lists of results, each list is a vector. I want to display > them on the same > graph, so I can compare them. How could I do that?You have to be more specific. What kind of vertors are they? Are they both numeric continuous variables? What kind of plot(s) do you want to draw? Assuming you have two continuous variables and you want to draw a scatter plot, one way to do it is to use plot(). For example: plot(x, y) Take a loot at ?plot to find out how to use it. Kevin -------------------------------------------- Ko-Kang Kevin Wang, MSc(Hon) Statistics Workshops Co-ordinator Student Learning Centre University of Auckland New Zealand
> -----Original Message----- > From: Justin Xi ZHU [mailto:j.zhu at imb.uq.edu.au] > Sent: Tuesday, February 17, 2004 2:30 PM > To: Ko-Kang Kevin Wang > Subject: RE: [R] plot > > > Hi, > > Thanks for your email. > > > Result 1: 23, 234, 45, 39 corresponding to Q1, Q2, Q3 and Q4. > Result 2: 123, 34, 454, 45 corresponding to Q1, Q2, Q3 and Q4. > > I would like to plot both result 1 and result 2 on the same > graph. The > x-axis is Q1, Q2, Q3 and Q4. I would like to compare two trends. > > Regards, JustinWhat you can do is to plot the question labels on the x-axis and use points (with different types/colours) and/or lies for the two "Results". You may want to take a look at the documentation for plot(), points() or lines(). I'm sure there are better plots, but I'll leave that to the other r-helpers to help you -- I'm too busy finishing up a consulting report *_*. Cheers, Kevin -------------------------------------------- Ko-Kang Kevin Wang, MSc(Hon) Statistics Workshops Co-ordinator Student Learning Centre University of Auckland New Zealand
Hello Justin, Monday, February 16, 2004, 10:10:21 PM, you wrote: JXZ> How could I plot two vectors on the same graph? For example, if I have two JXZ> lists of results, each list is a vector. I want to display them on the same JXZ> graph, so I can compare them. How could I do that? JXZ> Regards, Justin There several aproachs to that question. Something like plot(x, type ="l") lines(y) if both vectors have the same range... another is par(mfrow=c(1,2)) plot(x) plot(y) with each plot in diferent boxes... Still reading the plot help and par could be needed or Best regards, MMarques mailto:mmarques at power.inescn.pt