clips10
2010-Jun-17 13:55 UTC
[R] Plotting different symbols in R for different values in a vector
I have some point locations I want to add to a plot and have the command pts1<-as.points(Xcoordinate,Ycoordinate) then plot(poly1,type="l",lwd=1) what I want to do is add the locations onto the plot. I can do this using the points command but I have another vector in my data frame with the x and y coordinates called A for instance which takes values 1 and 0. I want to plot the locations onto my plot and have a different symbol or colour depending on whether this other vector takes the value 1 or 0. Is there anyway to do this? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Plotting-different-symbols-in-R-for-different-values-in-a-vector-tp2258833p2258833.html Sent from the R help mailing list archive at Nabble.com.
Sarah Goslee
2010-Jun-17 15:33 UTC
[R] Plotting different symbols in R for different values in a vector
Take a look at ?par - particularly the options for pch and col. Sarah On Thu, Jun 17, 2010 at 9:55 AM, clips10 <m.mcquillan at lancaster.ac.uk> wrote:> > I have some point locations I want to add to a plot and have the command > > pts1<-as.points(Xcoordinate,Ycoordinate) > > then > > > plot(poly1,type="l",lwd=1) > > what I want to do is add the locations onto the plot. I can do this using > the points command but I have another vector in my data frame with the x and > y coordinates called A for instance which takes values 1 and 0. I want to > plot the locations onto my plot and have a different symbol or colour > depending on whether this other vector takes the value 1 or 0. Is there > anyway to do this? > > Thanks > ---- Sarah Goslee http://www.functionaldiversity.org
Joris Meys
2010-Jun-17 15:39 UTC
[R] Plotting different symbols in R for different values in a vector
use the condition and par options, eg : x <- rnorm(10) y <- rnorm(10) A<- x<0 plot(x,y,type="l") points(x[A],y[A],pch=19,col="red") points(x[!A],y[!A],pch=21,col="blue",bg="green",lwd=2,cex=4) cheers Joris On Thu, Jun 17, 2010 at 3:55 PM, clips10 <m.mcquillan at lancaster.ac.uk> wrote:> > I have some point locations I want to add to a plot and have the command > > pts1<-as.points(Xcoordinate,Ycoordinate) > > then > > > plot(poly1,type="l",lwd=1) > > what I want to do is add the locations onto the plot. I can do this using > the points command but I have another vector in my data frame with the x and > y coordinates called A for instance which takes values 1 and 0. I want to > plot the locations onto my plot and have a different symbol or colour > depending on whether this other vector takes the value 1 or 0. Is there > anyway to do this? > > Thanks > -- > View this message in context: http://r.789695.n4.nabble.com/Plotting-different-symbols-in-R-for-different-values-in-a-vector-tp2258833p2258833.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. >-- Joris Meys Statistical consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control tel : +32 9 264 59 87 Joris.Meys at Ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php