[R] Scatter plot with multiple data sets

Joshua Wiley jwiley.psych at gmail.com
Thu Mar 3 23:43:24 CET 2011

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.

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



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

More information about the R-help mailing list