[R-gui] tkrplot and background colour

Wayne.W.Jones at shell.com Wayne.W.Jones at shell.com
Tue Feb 19 08:33:18 CET 2008


Hi Everyone, 

I have been using rpanel to produce a GUI for R. I came upon some formatting problems when using rp.tkrplot. 
Basically when I set the background of the tkrplot from "transparent" to "white" using the par functionality the dimensions of the plot change. 

The problem (if it really is one!) is not related to rpanel but to tkrplot. 

A reproducible example can be found below. 

Can anyone explain why this behaviour occurs?
Can anyone explain what settings are changing in the plots when the background colour is changed so 
that I can alter my code to accommodate this?

Regards

Wayne




library(tcltk)
library(tkrplot)
###### plot 1 with no background 

tt <- tktoplevel()
bb<-1
img <-tkrplot(tt, function() plot(1:20,(1:20)^bb))
f<-function(...) {
    b <- as.numeric(tclvalue("bb"))
    if (b != bb) {
        bb <<- b
        tkrreplot(img)
    }
}
s <- tkscale(tt, command=f, from=0.05, to=2.00, variable="bb",
             showvalue=FALSE, resolution=0.05, orient="horiz")
tkpack(img,s)


###### plot 2 with White background 

tt <- tktoplevel()
img <-tkrplot(tt, function() {par(bg="white"); plot(1:20,(1:20)^bb)})
s <- tkscale(tt, command=f, from=0.05, to=2.00, variable="bb",
             showvalue=FALSE, resolution=0.05, orient="horiz")
tkpack(img,s)






----------------------------------------------------------------------------------------
Wayne Jones
Statistical Consultant
Shell Global Solutions (UK)
Shell Technology Centre Thornton, P.O. Box 1, Chester CH1 3SH, United Kingdom

Tel: +44 (0) 151 373 5977 
Fax: +44 (0) 151 373 5384 
Mobile: +44 (0) 7896 536026
Email: Wayne.W.Jones at shell.com
Internet: www.shell.com/globalsolutions/statisticsandchemometrics

Shell Global Solutions (UK) is a division of Shell Research Limited which has its Registered Office at Shell Centre, London SE1 7NA and is registered in England & Wales with No.539964.



More information about the R-SIG-GUI mailing list