Hi I have a data table matrix,"data" which looks like below:- V1 V2 V3 1 -6382.719 -1096.554 6998994 2 -some values- 3 -some values- 4 -some values- 5 -some values- Querying dim of "data" gives me 3 columns and 5 rows. And currently I want to plot "V1" against "V2" with the condition that I want to mark(color) the point(row 5) on the graph. This is so i could see some triangle shape thing on the graph for row 5. I couldnt recall how I could use repo() to change the line 5 to some value to differentiate with others. And then using PCH for the color. Please advise. Thanks. -jason [[alternative HTML version deleted]]
try this: x <- matrix(runif(15, 100, 300), ncol=3) plot(x[,1], x[,2], type='l') points(x[5,1], x[5,2], pch=17, cex=3, col='red') # plot point #5 On Fri, May 23, 2008 at 8:50 AM, Jason Lee <huajie.lee@gmail.com> wrote:> Hi > > I have a data table matrix,"data" which looks like below:- > V1 V2 V3 > 1 -6382.719 -1096.554 6998994 > 2 -some values- > 3 -some values- > 4 -some values- > 5 -some values- > > Querying dim of "data" gives me 3 columns and 5 rows. > > And currently I want to plot "V1" against "V2" with the condition that I > want to mark(color) the point(row 5) on the graph. This is so i could see > some triangle shape thing on the graph for row 5. > > I couldnt recall how I could use repo() to change the line 5 to some value > to differentiate with others. And then using PCH for the color. > > Please advise. Thanks. > > -jason > > [[alternative HTML version deleted]] > > ______________________________________________ > 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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
Hi I tried and it is not what im looking .. I basically issue plot(data$"V1",data$"V2") as the matrix have the two headers..But essentially what I would like is relabel or somehow differentiate row 5 from the rest of the points on the graph. In other words, I wanted to see all the points but at the same time see the particular point (row 5 in this case) on the graph as another point of color in the graph. Please advise. Thanks., On Fri, May 23, 2008 at 11:00 PM, jim holtman <jholtman@gmail.com> wrote:> try this: > > x <- matrix(runif(15, 100, 300), ncol=3) > plot(x[,1], x[,2], type='l') > points(x[5,1], x[5,2], pch=17, cex=3, col='red') # plot point #5 > > On Fri, May 23, 2008 at 8:50 AM, Jason Lee <huajie.lee@gmail.com> wrote: > >> Hi >> >> I have a data table matrix,"data" which looks like below:- >> V1 V2 V3 >> 1 -6382.719 -1096.554 6998994 >> 2 -some values- >> 3 -some values- >> 4 -some values- >> 5 -some values- >> >> Querying dim of "data" gives me 3 columns and 5 rows. >> >> And currently I want to plot "V1" against "V2" with the condition that I >> want to mark(color) the point(row 5) on the graph. This is so i could see >> some triangle shape thing on the graph for row 5. >> >> I couldnt recall how I could use repo() to change the line 5 to some value >> to differentiate with others. And then using PCH for the color. >> >> Please advise. Thanks. >> >> -jason >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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<http://www.r-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem you are trying to solve?[[alternative HTML version deleted]]
> > > From: "Jason Lee" <huajie.lee@gmail.com> > Date: May 23, 2008 10:06:18 AM EDT > To: r-help@r-project.org > Subject: [R] Fwd: Advise in R- plotting graphs > > > Hi > > I tried and it is not what im looking .. > > I basically issue plot(data$"V1",data$"V2") as the matrix have the two > headers..But essentially what I would like is relabel or somehow > differentiate row 5 from the rest of the points on the graph.If I understand correctly what you want the code provided by Jim Holtman works provided you omit the " type = "l" " part. If you convert the matrix to a data frame you can use the ggplot2 package to do this kind of thing very flexibly (see code below)> > > In other words, I wanted to see all the points but at the same time > see the > particular point (row 5 in this case) on the graph as another point > of color > in the graph. > > Please advise. > > Thanks., > > > > On Fri, May 23, 2008 at 11:00 PM, jim holtman <jholtman@gmail.com> > wrote: > >> try this: >> >> x <- matrix(runif(15, 100, 300), ncol=3) >> plot(x[,1], x[,2], type='l') >> points(x[5,1], x[5,2], pch=17, cex=3, col='red') # plot point #5#Alternative solution using ggplot2# x2 <- data.frame(x) x2$factor <- factor(c(1,1,1,1,2)) library(ggplot2) qplot(X1,X2, data=x2, colour=factor)>> >> >> On Fri, May 23, 2008 at 8:50 AM, Jason Lee <huajie.lee@gmail.com> >> wrote: >> >>> Hi >>> >>> I have a data table matrix,"data" which looks like below:- >>> V1 V2 V3 >>> 1 -6382.719 -1096.554 6998994 >>> 2 -some values- >>> 3 -some values- >>> 4 -some values- >>> 5 -some values- >>> >>> Querying dim of "data" gives me 3 columns and 5 rows. >>> >>> And currently I want to plot "V1" against "V2" with the condition >>> that I >>> want to mark(color) the point(row 5) on the graph. This is so i >>> could see >>> some triangle shape thing on the graph for row 5. >>> >>> I couldnt recall how I could use repo() to change the line 5 to >>> some value >>> to differentiate with others. And then using PCH for the color. >>> >>> Please advise. Thanks. >>> >>> -jason >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> 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<http://www.r-project.org/posting-guide.html >>> > >>> and provide commented, minimal, self-contained, reproducible code[[alternative HTML version deleted]]
Jason Lee-14 wrote:> > I want to plot "V1" against "V2" with the condition that I > want to mark(color) the point(row 5) on the graph. This is so i could see > some triangle shape thing on the graph for row 5. > >You could try something crude like plot(V1,V2, col=ifelse( (1:length(V1)) == 5, "red","black") ) or plot(V1,V2, pch=ifelse( (1:length(V1)) == 5, 1,2) ) -- View this message in context: http://www.nabble.com/Advise-in-R--plotting-graphs-tp17424911p17452851.html Sent from the R help mailing list archive at Nabble.com.