Re: [R] Scatter plot with multiple data sets

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Thu, 03 Mar 2011 14:43:24 -0800

Hi Joe,

The easiest option will be to combine all 6 datasets (at least the variables you want to use in your scatter plot), and then create another variable that indicates to which group the observations belong. Here is a small example of what you might do once your data are all together (obviously replace "mtcars" with your dataset name and the variables with your variables):

with(mtcars, plot(x = hp, y = mpg, pch = carb))

I am also fond using the ggplot2 package for graphs.

require(ggplot2)
ggplot(mtcars, aes(x = hp, y = mpg, shape = factor(carb))) + geom_point()

Cheers,

Josh

On Thu, Mar 3, 2011 at 12:03 PM, Jorseff <jcp512_at_york.ac.uk> wrote:
> Hi, I have multiple (6) data sets which I would like to plot together on one
> scatter graph. The reason they are all separate is that I require a
> different symbol to be plotted for each set. Could somebody advise on how to
> do this?
>
> Many thanks,
>
> Joe
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Scatter-plot-with-multiple-data-sets-tp3334096p3334096.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.
>

-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.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.
Received on Thu 03 Mar 2011 - 22:57:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Mar 2011 - 23:00:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive