This peice of very useful getcell() function was posted for me on this
list by Duncan Murdoch (Thanks again Duncan). It allows the
identification of a particular plot in a matrix of plots. All you need
to do then is use this information to identify the original plot which
you can then re-plot.
###### Start Function ######
getcell <- function(pts = locator()) {
usr <- par("usr")
plt <- par("plt")
mfg <- par("mfg")
x <- pts$x
y <- pts$y
# convert to 0-1 plot coordinates
px <- (x-usr[1])/(usr[2]-usr[1])
py <- (y-usr[3])/(usr[4]-usr[3])
# convert to 0-1 frame coordinates
fx <- plt[1] + px*(plt[2]-plt[1])
fy <- plt[3] + py*(plt[4]-plt[3])
# convert to a relative cell position
cx <- floor(fx)
cy <- floor(fy)
# return the absolute cell position
list(row = -cy+mfg[1],col = cx+mfg[2])
}
####### End Function #######
#For example
Dset1<-1:10
Dset2<-rnorm(10)
oldpar<-par(mfrow=c(2,1))
plot(Dset1)
plot(Dset2)
cell<-getcell(locator(1))
if((cell$row*cell$col)<2){
par(mfrow=c(1,1))
plot(Dset1)
} else {
par(mfrow=c(1,1))
plot(Dset2)
}
I hope this gives you something to work with.
Tom
On Fri, 2005-18-11 at 09:46 -0500, Vasundhara Akkineni
wrote:> Hi all,
> I am trying to display a matrix of plots(images), for example a 3*3 matrix
> of 9 image plots, such that when a user clicks on a image i can show the
> enlarged plot. I tried the multiple graphic device(using mfcol=c(3,3) and
> mfg), but it creates multiple plots in a single image file. So, i won't
be
> able to highlight a particular plot when the user clicks on it.
> To be more clear, can i display images in the form of a matrix in R. Are
> there any grids available? Please let me know.
> Thanks,
> Vasu.
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
>