[R] how do i put two scatterplots on same graph

William Revelle lists at revelle.net
Tue Oct 4 17:16:24 CEST 2011



If the data are from one data.frame (e.g., the iris data set), then simply label the red and white flowers with different colors:
e.g.,

with the iris data set

plot(iris$Sepal.Length,iris$Sepal.Width,col=c("red","blue","black")[iris$Species],pch=c(16:18)[iris$Species])

Bill




On Oct 4, 2011, at 4:20 AM, Paul Hiemstra wrote:

> On 10/04/2011 06:19 AM, jricci wrote:
>> Have two sets of scatterplot data
>> hypothetically  
>> a) stem lenght vs number of petals in red flowers
>> b) stem lenght vs number of petals in white flowers
>> 
>> want to place on same scatter plot with same x,y axis but different collored
>> markers
>> 
>> How do I do this in R
>> 
>> --
>> View this message in context: http://r.789695.n4.nabble.com/how-do-i-put-two-scatterplots-on-same-graph-tp3870030p3870030.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.
> 
> Hi,
> 
> You could take a look at the ggplot2 package.
> 
> good luck,
> Paul
> 
> -- 
> Paul Hiemstra, Ph.D.
> Global Climate Division
> Royal Netherlands Meteorological Institute (KNMI)
> Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
> P.O. Box 201 | 3730 AE | De Bilt
> tel: +31 30 2206 494
> 
> http://intamap.geo.uu.nl/~paul
> http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
> 
> ______________________________________________
> 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.
> 

William Revelle		           http://personality-project.org/revelle.html
Professor			           http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University	   http://www.northwestern.edu/
Use R for psychology             http://personality-project.org/r
It is 6 minutes to midnight	   http://www.thebulletin.org



More information about the R-help mailing list