[R] identify function with postscript output?

Ross Ihaka ihaka at stat.auckland.ac.nz
Thu Nov 13 18:57:52 CET 2003

U.Ramakrishna wrote:
> Hello,
> I want to select some points in a plot using 'identify' function
> and also want the identified points to be saved in a
> postscript file? Any help in how to do it?
> A better question might have been, how do i pipe the screen output
> to a postscript file?

You may want to look at the "pos" argument to "identify" and "text". 
Specifying pos=TRUE as an argument to "identify" makes it add a "pos" 
component to its return value.  This can be passed as an argument "text" 
to place the labels in new plots just as they appear in the on-screen 


 > #  Onscreen
 > y = rnorm(10)
 > plot(y)
 > id = identify(y,pos=TRUE)

 > #  Later, for hardcopy
 > postscript()
 > plot(y)
 > text(1:length(y)[id$ind], y[id$ind], labels=id$ind, pos=id$pos)
 > dev.off()

That way you can capture the essential state of your on-screen plot,
but make revisions to the way in which its drawn.

Ross Ihaka                         Email:  ihaka at stat.auckland.ac.nz
Department of Statistics           Phone:  (64-9) 373-7599 x 85054
University of Auckland             Fax:    (64-9) 373-7018
Private Bag 92019, Auckland
New Zealand

More information about the R-help mailing list