Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
two connected graphs
5 messages · robin hankin, John Kane, Charles C. Berry +2 more
--- Robin Hankin <r.hankin at noc.soton.ac.uk> wrote:
Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this?
?par and read up on mfrow for the two graphs. Here is something that may help for the lines http://finzi.psych.upenn.edu/R/Rhelp02a/archive/1926.html The code below will work but I had to figure out the arrow coordinates by trial and error and there must be a better way. aa <- c(1:10) bb <- c(1:6) op <- par(mfrow = c(2,1), oma=c(1,0,3,0), las=1, xpd = NA ) plot(aa) plot(bb) arrows( 3,3, 4.9, 21.5, length=0)
On Thu, 14 Dec 2006, Robin Hankin wrote:
Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this?
Use the grid package. You'll want to study the xscale arg of the viewport function (to set up your two plots using the same scale) Calls to grid.move.to, seekViewport, and grid.line.to can be used to connect points in different plots (viewports)
[...]
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717
Hi
Charles C. Berry wrote:
On Thu, 14 Dec 2006, Robin Hankin wrote:
Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this?
Use the grid package. You'll want to study the xscale arg of the viewport function (to set up your two plots using the same scale) Calls to grid.move.to, seekViewport, and grid.line.to can be used to connect points in different plots (viewports)
See the example in "The grid Graphics Package" R News 2(2) http://cran.r-project.org/doc/Rnews/Rnews_2002-2.pdf Paul
[...]
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717
______________________________________________ R-help at stat.math.ethz.ch 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.
Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 paul at stat.auckland.ac.nz http://www.stat.auckland.ac.nz/~paul/
If you're not already familiar with M & N plots (by Diaconis and Friedman), you should have a look at: http://www.slac.stanford.edu/cgi-wrap/getdoc/slac-pub-2495.pdf Hadley
On 12/14/06, Robin Hankin <r.hankin at noc.soton.ac.uk> wrote:
Hi I have two datasets, A and B, consisting of two columns of numbers representing x and y coordinates. They have 10 and 6 rows respectively. I want to plot two scattergraphs, one above the other. The lower graph to contain A (10 points) and the upper graph to contain B (six points). The x-axes of the two graphs must line up. I then want to draw straight lines that connect points of B to a particular point (or points) of A. How do I do this? -- Robin Hankin Uncertainty Analyst National Oceanography Centre, Southampton European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
______________________________________________ R-help at stat.math.ethz.ch 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.