[R] Interactive plots with R
Andris Jankevics
andza at osi.lv
Wed Jan 31 12:50:30 CET 2007
Hi,
I wrote some simple rpanel package script for visual spectral data comparison.
At this example i have a three samples and i want to zoom through x and y
axis to compare differences between samples. With my script below I can zoom
to some data region and add some other spetra to the plot, through text input
field.
But I can't figure out, how to change axis scaling for all displayed spectra,
because only first spectra are redrawed after axis scaling.
Or maybe I need to study samples and documentation for tcltk package?
My script:
DATAPPM=seq(0,11,0.004)
DATAPPM=data.frame(DATAPPM,DATAPPM,DATAPPM)
DATAS=data.frame
(S1=sample(1:3260,2751),S2=sample(1:3260,2751),S3=sample(1:3260,2751))
library (rpanel)
pplotNMR <- function (panel) {
with (panel,{
VECP <- DATAPPM[,sample]
VECS <- DATAS[,sample]
names (VECP) <- rownames(DATAPPM)
names (VECS) <- rownames(DATAS)
SEL <- names(VECP[VECP>MIN & VECP<MAX])
VECP <- VECP[SEL]
VECS <- VECS[SEL]
plot (VECP,VECS,type="l",xlim=c(MAX,MIN),xlab="PPM",ylab="intensity",
ylim=c(YMIN,YMAX))
panel})
}
pplotNMRadd<- function (panel) {
with (panel, {
sample <- as.numeric (sample.text)
VECP <- DATAPPM[,sample]
VECS <- DATAS[,sample]
names (VECP) <- rownames(DATAPPM)
names (VECS) <- rownames(DATAS)
SEL <- names(VECP[VECP>MIN & VECP<MAX])
VECP <- VECP[SEL]
VECS <- VECS[SEL]
points (VECP,VECS,type="l",col=sample)
panel })
}
panel <- rp.control (title="NMR
control",MIN=-2,MAX=12,sample=1,YMAX=max(apply(DATAS,2,max)),YMIN=min(apply(DATAS,2,min)),sample.text=1)
rp.slider(panel,MIN,from=-2,to=12,showvalue=TRUE,action=pplotNMR,title="ppm
min")
rp.slider(panel,MAX,from=-2,to=12,showvalue=TRUE,action=pplotNMR,title="ppm
max")
rp.slider(panel,YMAX,from=YMIN,to=max(apply(DATAS,2,max)),showvalue=TRUE,action=pplotNMR,title="Intesity")
rp.doublebutton (panel,YMAX,step=10,action=pplotNMR,title="intensity,
step=10",showvalue=TRUE)
rp.textentry (panel, sample.text, action=pplotNMRadd, title="Add sample to
plot:")
Thanks and regards,
Andris Jankevics
More information about the R-help
mailing list