I have a dataframe (x) and I'm plotting the 5th column vs the index. I also have a vector (v) with a few select points that I want to emphasize with a dot for those points> head(x)period AP EU LA NA 1 Jan 2007 0.18 0.45 0.19 3.19 2 Feb 2007 0.14 0.48 0.36 3.55 3 Mar 2007 0.14 0.42 0.46 2.61 4 Apr 2007 0.24 0.73 0.32 4.32 5 May 2007 0.19 0.60 0.32 4.40 6 Jun 2007 0.14 0.38 0.32 1.09 v <-c(2,4,7) plot(x[,5], type='l') How do I put a solid dot at just the points I want to highlight ? In other words, a solid dot a the 2nd, 4th, and 7th point on the plot. All other points according the the type='l'. I tried ... points(x[v,5], pch=19) ... but the points didn't plot in the right spot. -- View this message in context: http://r.789695.n4.nabble.com/Plotting-specific-points-with-type-l-tp4650475.html Sent from the R help mailing list archive at Nabble.com.
try this> # you need to provide sample data > x <- runif(10) > v <- c(2, 4, 7) > plot(x, type = 'l') > # highlight points > points(v, x[v], pch = 19) >On Thu, Nov 22, 2012 at 2:22 PM, eric <ericstrom at aol.com> wrote:> I have a dataframe (x) and I'm plotting the 5th column vs the index. I also > have a vector (v) with a few select points that I want to emphasize with a > dot for those points > >> head(x) > period AP EU LA NA > 1 Jan 2007 0.18 0.45 0.19 3.19 > 2 Feb 2007 0.14 0.48 0.36 3.55 > 3 Mar 2007 0.14 0.42 0.46 2.61 > 4 Apr 2007 0.24 0.73 0.32 4.32 > 5 May 2007 0.19 0.60 0.32 4.40 > 6 Jun 2007 0.14 0.38 0.32 1.09 > > v <-c(2,4,7) > plot(x[,5], type='l') > > How do I put a solid dot at just the points I want to highlight ? In other > words, a solid dot a the 2nd, 4th, and 7th point on the plot. All other > points according the the type='l'. I tried ... points(x[v,5], pch=19) ... > but the points didn't plot in the right spot. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/Plotting-specific-points-with-type-l-tp4650475.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.-- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it.
Hi, If you wanted to emphasize the select points from the 5th column: You could try: plot(x[,5], type='l') ?points(dat2[c(2,4,7),5],pch=19) A.K. ----- Original Message ----- From: eric <ericstrom at aol.com> To: r-help at r-project.org Cc: Sent: Thursday, November 22, 2012 2:22 PM Subject: [R] Plotting specific points with type='l' I have a dataframe (x) and I'm plotting the 5th column vs the index. I also have a vector (v) with a few select points that I want to emphasize with a dot for those points> head(x)? ? period? AP? EU? LA? NA 1 Jan 2007 0.18 0.45 0.19 3.19 2 Feb 2007 0.14 0.48 0.36 3.55 3 Mar 2007 0.14 0.42 0.46 2.61 4 Apr 2007 0.24 0.73 0.32 4.32 5 May 2007 0.19 0.60 0.32 4.40 6 Jun 2007 0.14 0.38 0.32 1.09 v <-c(2,4,7) plot(x[,5], type='l') How do I put a solid dot at just the points I want to highlight ? In other words, a solid dot a the 2nd, 4th, and 7th point on the plot. All other points according the the type='l'. I tried ... points(x[v,5], pch=19) ... but the points didn't plot in the right spot. -- View this message in context: http://r.789695.n4.nabble.com/Plotting-specific-points-with-type-l-tp4650475.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.