I'm trying to duplicate some graphs from powerpoint in R package. One of things I'm having trouble with is I don't understand how to use the points command to create different sets of points with different color and marking attributes, and a legend on the graph. Where should I look? I can't seem to find an example of two different sets of data on the same graph. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Collin Carbno wrote:> > I'm trying to duplicate some graphs from powerpoint in R package.??? Which R package do you mean? Do you want to import a graph into R? Why?> One > of things I'm having trouble with is I don't understand how to use the > points command to create different sets of points with different color > and marking attributes, and a legend on the graph. Where should I look? > I can't seem to find an example of two different sets of data on the > same graph.1. Read "An Introduction to R" 2. Look at the help for points(): ?points , particularly the examples. 3. Look at the help for legend(): ?legend Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi, you should use col= and pch= graphical parameters for point type and color correspondingly. Legend get you with legend(). E.g. you can plot:> x <- 1:10 > y1 <- x > y2 <- sqrt(x) > y3 <- log(x) > plot(x,y1) > points(x,y2,pch=2,col=3) > points(x,y3,pch=3,col=4) > legend(1.5,9, legend=c(expression(x), expression(sqrt(x)), expression(log(x))), pch=c(1,2,3), col=c(1,3,4))instead of points(), you can consider also lines() wich draws a lines as default. The line type is controlled by lty= parameter. To see different possible point- and color types, use> plot(0:30, pch=0:30, col=0:30)Perhaps it helps. Ott Toomet On Tue, 29 Jan 2002, Collin Carbno wrote:> I'm trying to duplicate some graphs from powerpoint in R package. One > of things I'm having trouble with is I don't understand how to use the > points command to create different sets of points with different color > and marking attributes, and a legend on the graph. Where should I look? > I can't seem to find an example of two different sets of data on the > same graph. > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello Collin, The thing with different colors, symbols or size is very easy. Just give a vector with as many elements as points you want to the function points. points(c(x1,x2,x3,x4,x5),c(y1,y1,y2,y3,y4,y5),col=c(col1,col2,col3,col4,col5),phc=(pch1,pc...),cex=c(....)) the same thing also works in plot, text, lines and so on, and also for the arguments lty (line typ) If your vector is too short it will be duplicated as many time as neccessary. In this case col=c('black','blue') will produce alternating colors. with legends i don't have much experience. I often do it with 'text' and 'points'. But there is a function called legend. I should also have to look to it. gruess joerg Collin Carbno wrote:> > I'm trying to duplicate some graphs from powerpoint in R package. One > of things I'm having trouble with is I don't understand how to use the > points command to create different sets of points with different color > and marking attributes, and a legend on the graph. Where should I look? > I can't seem to find an example of two different sets of data on the > same graph. > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Joerg Maeder .:|:||:..:.||.:: maeder at atmos.umnw.ethz.ch Tel: +41 1 633 36 25 .:|:||:..:.||.:: http://www.iac.ethz.ch/staff/maeder PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH) ETH Z?RICH Switzerland -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Collin Carbno wrote:> > I'm trying to duplicate some graphs from powerpoint in R package. One > of things I'm having trouble with is I don't understand how to use the > points command to create different sets of points with different color > and marking attributes, and a legend on the graph. Where should I look? > I can't seem to find an example of two different sets of data on the > same graph.You can use points() or lines() to add points or lines to an existing plot. See the help pages, there are a lot of examples on how to use these functions. Use legend() to add a legend to a plot (and there are also a lot of examples on how to use legend()). But you can also build your legend with text(), polygon(), lines() etc if you prefer a flexible style. See (for example) http://cran.r-project.org/doc/contrib/rpsych.pdf on how to build a legend with text(), polygon() etc. By, Sven -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi Collin, you can also try overlaying plots using par(new=...) plot(x,y1) par(new=TRUE) plot(x,y2) this plots in the same device, but take care with the annotations by using par(ann=F) to suppress them good luck Benjamin Warr Research Associate Centre for the Management of Environmental Resource(CMER) INSEAD> -----Original Message----- > From: Collin Carbno [mailto:collin.carbno at sk.sympatico.ca] > Sent: 30 January 2002 02:20 > To: r-help at hypatia.math.ethz.ch > Subject: [R] multiple series on same graph > > > I'm trying to duplicate some graphs from powerpoint in R package. One > of things I'm having trouble with is I don't understand how to use the > points command to create different sets of points with different color > and marking attributes, and a legend on the graph. Where > should I look? > I can't seem to find an example of two different sets of data on the > same graph. > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. > -.-.-.-.-.-.-.-.- > r-help mailing list -- Read > http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: > r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. > _._._._._._._._._ >-------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20020130/f363397b/attachment.html