Grid and ungrid plot using R and tcltk

493 views Asked by At

I plot data in a tcl tk window like this.

a <- tktoplevel()
b <- tkrplot(a, function()plot(cars, col="red"))
tkpack(b)

In my window, I use check button to put or remove grid to the plot.

require(tcltk)
require(tkrplot)

a <- tktoplevel()
tkbind(a, "<Destroy>", function()if(exists("cbValue"))tclvalue(cbValue) <- "3")
b <- tkrplot(a, function()plot(cars, col="red"))
tkpack(b)

cb <- tkcheckbutton(a)
cbValue <- tclVar("0")
tkconfigure(cb,variable=cbValue)
tkpack(cb)

x <- TRUE
while(x){
    tkwait.variable(cbValue)
    if(tclvalue(cbValue)=="1")
        tkrreplot(b, function(){ plot(cars, col="red"); grid() })
    else if(tclvalue(cbValue)=="0")
        tkrreplot(b, function()plot(cars, col="red"))
    else x <- FALSE
}

My problem is : In this example, I use cars data but actually I use a huge data. So, the method above (plot and then replot) takes too long do be done.

My question is : Is there a way to definetely plot the graph, and then add or remove grid without replotting it ?

THank you.

0

There are 0 answers