[R] Adding points sequentially to multiple graphs in one window (device)

elinder at unh.edu elinder at unh.edu
Wed Aug 11 20:50:11 CEST 2010


Dear R-help list:

I have want seems to be a simple task, but can't find a solution.
I tried querying the archives, but did not succeed.

My goal is to set up two (or more) graphs in one graph window, and
then during execution of a sequential algorithm add points
sequentially to these graphs. The graphs have different scales
/ coordinates. I use the par(mfg...) command to
switch between graphs.  The problem is:
This only plots points correctly in the
last of the graphs.  When I try to add a point to say the first
graph, it is incorrect, namely it plots that point relative to
the coordinate system of the last graph, not the first graph.

How can I avoid this problem?

I work with older and newer versions of R and both on Windows XP
and on Mac OS.10.5.

Here is a simple script to illustrate my dilemma:

par(mfrow=c(2,1),mar=c(4,4,1,1))
plot(1:40,1:40,type='n')
plot(1:20,1:20,type='n')
par(mfg=c(1,1)); points(15,5)  #  this plots incorrectly
par(mfg=c(2,1)); points(15,5)  #  this plots correctly


Any help or pointers would be greatly appreciated.


Ernst Linder

-- 
Ernst Linder     elinder at unh.edu
Professor of Statistics
Dept. of Mathematics and Statistics
University of New Hampshire
Phone:  603 862 2687 (work)



More information about the R-help mailing list