I am trying to produce a simple plot where the points in the plot are actually integers from my data. That is, I am making a length/width plot and I would like the points, rather dots or triangles, appear as different numbers corresponding to a column in my data. I have tried using this: ...,pch="column title" but this merely returns the first letter of the column title, B. Is there any way to do this? I am using R 2.7.1 and Ubuntu 8.04. Thanks. -- View this message in context: http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307460.html Sent from the R help mailing list archive at Nabble.com.
Hi Hippien Dream If I understood, the code below may help you. Cheers, Miltinho Astronauta Brazil == x<-runif(20) y<-rnorm(20) df<-data.frame(cbind(x,y)) par(mfrow=c(1,2)) plot(y~x, data=df) plot(y~x, data=df, type="n") text(df$x, df$y, "o.o") On 7/6/08, hippie dream <tonightsthenight@gmail.com> wrote:> > > I am trying to produce a simple plot where the points in the plot are > actually integers from my data. That is, I am making a length/width plot > and > I would like the points, rather dots or triangles, appear as different > numbers corresponding to a column in my data. I have tried using this: > > ...,pch="column title" > > but this merely returns the first letter of the column title, B. Is there > any way to do this? > > I am using R 2.7.1 and Ubuntu 8.04. Thanks. > -- > View this message in context: > http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307460.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. >[[alternative HTML version deleted]]
below is milton's example with the text command changed to be the values of y itself ? is that what you wanted ? x<-runif(20) y<-rnorm(20) df<-data.frame(cbind(x,y)) plot(y~x, data=df, type="n") text(df$x, df$y, df$y) On Sun, Jul 6, 2008 at 6:59 PM, hippie dream wrote:> Thanks Milton, > > I am finding this a little hard to explain. The code you gave me > produced > all 0.0 points whereas what I am looking for are the points to > correspond to > a specific column. I'll be explicit. I am graphing the location of 15 > objects numbered 1 to 15. > > plot(Length ~ Width, data=infiltration1, col="blue", xlab = "Width > (cm)", > ylab = "Length (m)", xlim=c(0,200), ylim=c(0,30)) > > Now I would like the points on this graph, rather than dots to be > numbers > corresponding to the object it represents. Is there any way to > "access" the > object number from my data to use as in lieu of points? > > Thanks again. > > > milton ruser wrote: >> >> Hi Hippien Dream >> >> If I understood, the code below may help you. >> >> Cheers, >> >> Miltinho Astronauta >> Brazil >> ==>> >> >> >> x<-runif(20) >> y<-rnorm(20) >> >> df<-data.frame(cbind(x,y)) >> >> par(mfrow=c(1,2)) >> plot(y~x, data=df) >> >> plot(y~x, data=df, type="n") >> text(df$x, df$y, "o.o") >> >> >> >> >> >> >> On 7/6/08, hippie dream <tonightsthenight at gmail.com> wrote: >>> >>> >>> I am trying to produce a simple plot where the points in the plot >>> are >>> actually integers from my data. That is, I am making a length/width >>> plot >>> and >>> I would like the points, rather dots or triangles, appear as >>> different >>> numbers corresponding to a column in my data. I have tried using >>> this: >>> >>> ...,pch="column title" >>> >>> but this merely returns the first letter of the column title, B. Is >>> there >>> any way to do this? >>> >>> I am using R 2.7.1 and Ubuntu 8.04. Thanks. >>> -- >>> View this message in context: >>> >>> http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307460.html >>> Sent from the R help mailing list archive at Nabble.com. >>> >>> ______________________________________________ >>> 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. >>> >> >> [[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. >> >> > > -- > View this message in context: > http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307655.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
I think what he is trying to do is more on the following lines: D<-NULL; for(i in (1:5)){D<-cbind(D,2.5*i+(0:10)+ 0.5*rnorm(11))} {plot((0:10),D[,1],pch=49,col="blue",ylim=c(0,25))} for(i in (2:5)){points((0:10),D[,i],pch=(48+i),col="blue")} Ted. On 06-Jul-08 22:47:49, milton ruser wrote:> Hi Hippien Dream > > If I understood, the code below may help you. > > Cheers, > > Miltinho Astronauta > Brazil > ==> > > > x<-runif(20) > y<-rnorm(20) > > df<-data.frame(cbind(x,y)) > > par(mfrow=c(1,2)) > plot(y~x, data=df) > > plot(y~x, data=df, type="n") > text(df$x, df$y, "o.o") > > > > > > > On 7/6/08, hippie dream <tonightsthenight at gmail.com> wrote: >> >> >> I am trying to produce a simple plot where the points in the plot are >> actually integers from my data. That is, I am making a length/width >> plot >> and >> I would like the points, rather dots or triangles, appear as different >> numbers corresponding to a column in my data. I have tried using this: >> >> ...,pch="column title" >> >> but this merely returns the first letter of the column title, B. Is >> there >> any way to do this? >> >> I am using R 2.7.1 and Ubuntu 8.04. Thanks. >> -- >> View this message in context: >> http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307460.h >> tml >> Sent from the R help mailing list archive at Nabble.com. >> >> ______________________________________________ >> 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. >> > > [[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.-------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 07-Jul-08 Time: 00:22:14 ------------------------------ XFMail ------------------------------
milton: that was totally your solution. i just changed it for what hippie dream wanted. hippie dream: you can do ?text to get a better explanation but the basic idea is that the first two parameters in text specify the coordinates at which you put the text and the third param is the text. so, y is there twice because in the first case, y acts as a coordinate and in the second case, y acts as a label. On Sun, Jul 6, 2008 at 7:12 PM, milton ruser wrote: Thanks Mark Leeds! Just putting something more on the code: x<-runif(20) y<-rnorm(20) code.level<-sample(1:15,20, replace=T) df<-data.frame(cbind(x,y, code.level)) plot(y~x, data=df, type="n") text(df$x, df$y, df$code.level) Peace, Miltinho Astronauta Brazil On 7/6/08, markleeds@verizon.net <mailto:markleeds@verizon.net> < markleeds@verizon.net <mailto:markleeds@verizon.net> > wrote: below is milton's example with the text command changed to be the values of y itself ? is that what you wanted ? x<-runif(20) y<-rnorm(20) df<-data.frame(cbind(x,y)) plot(y~x, data=df, type="n") text(df$x, df$y, df$y) On Sun, Jul 6, 2008 at 6:59 PM, hippie dream wrote: Thanks Milton, I am finding this a little hard to explain. The code you gave me produced all 0.0 points whereas what I am looking for are the points to correspond to a specific column. I'll be explicit. I am graphing the location of 15 objects numbered 1 to 15. plot(Length ~ Width, data=infiltration1, col="blue", xlab = "Width (cm)", ylab = "Length (m)", xlim=c(0,200), ylim=c(0,30)) Now I would like the points on this graph, rather than dots to be numbers corresponding to the object it represents. Is there any way to "access" the object number from my data to use as in lieu of points? Thanks again. milton ruser wrote: Hi Hippien Dream If I understood, the code below may help you. Cheers, Miltinho Astronauta Brazil == x<-runif(20) y<-rnorm(20) df<-data.frame(cbind(x,y)) par(mfrow=c(1,2)) plot(y~x, data=df) plot(y~x, data=df, type="n") text(df$x, df$y, "o.o") On 7/6/08, hippie dream < tonightsthenight@gmail.com <mailto:tonightsthenight@gmail.com> > wrote: I am trying to produce a simple plot where the points in the plot are actually integers from my data. That is, I am making a length/width plot and I would like the points, rather dots or triangles, appear as different numbers corresponding to a column in my data. I have tried using this: ...,pch="column title" but this merely returns the first letter of the column title, B. Is there any way to do this? I am using R 2.7.1 and Ubuntu 8.04. Thanks. -- View this message in context: http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307460.html <http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307460.html> Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org <mailto:R-help@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org <mailto:R-help@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307655.html <http://www.nabble.com/Numbers-as-Points-in-Graphs-tp18307460p18307655.html> Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org <mailto:R-help@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org <mailto:R-help@r-project.org> mailing list https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. <http://www.r-project.org/posting-guide.html> [[alternative HTML version deleted]]