[R] scatter plot matrix with different x-y variables
jrkrideau at inbox.com
Wed May 8 20:56:38 CEST 2013
Several ways but I find that grid.arrange in the gridExtra package combined with ggplot2 to draw the actual graphs works nicely.
You might also want to look mfcol or mfrow in ?par
### quick and dirty example of ggplot2/gridExtra
mdat <- data.frame(a= 1:5, b=1:5)
ndat <- data.frame(x = rnorm(20), y = rnorm(20))
p <- ggplot(mdat , aes(a,b, colour = 'red' )) + geom_point() +
q <- ggplot(ndat , aes( x, y )) + geom_line()
I imagine that you will need to install the ggplot2 and gridExtra packages. See ?install.packages for help
Kingston ON Canada
> -----Original Message-----
> From: adeldaoud at gmail.com
> Sent: Wed, 8 May 2013 09:49:25 -0700 (PDT)
> To: r-help at r-project.org
> Subject: [R] scatter plot matrix with different x-y variables
> Dear list-members,
> I wonder if there is a way of creating a scatter plot table/grid with
> different variables on the y-axis compared to the x-axis? Something like
> I know that you can create scatter plot matrix with the same variables on
> y-axis as on the x-axis, like this:
> But this is not what I want. I basically want to get a visual
> representation of different dependent variables (y-axis) on various
> independent variables (x-axis). So I want it to look like a scatter plot
> matrix or grid, but with my own specified variables on each axis.
> Secondly, to add to this, can I add a correlation line (linear and
> through all scatter plots with both correlation and R2 values?
> All help appreciated.
> Adel Daoud, PhD
> Department of Sociology, University of Gothenburg
> Box 720
> 405 30 GC6teborg, SWEDEN
> Visiting address: SprC$ngkullsgatan 25, room F411
> +46 031-786 47 84
> Adel.daoud at sociology.gu.se
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
More information about the R-help