[R] two connected graphs

Charles C. Berry cberry at tajo.ucsd.edu
Thu Dec 14 18:06:43 CET 2006


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



More information about the R-help mailing list