A Slider to Control Two Plotting Windows

September 28, 2010

(This article was first published on Statistics, R, Graphics and Fun » R Language, and kindly contributed to R-bloggers)

One of my readers asked two weeks ago how to control two graphics windows with the slider in gWidgets. Here is a simple example:

if (!require("gWidgetsRGtk2")) install.packages("gWidgetsRGtk2")
options(guiToolkit = "RGtk2")

gslider(from = 1, to = 100, value = 10,
    container = gwindow("Two Plotting Windows"),
    handler = function(h, ...) {
        n = 10 * svalue(h$obj)
        plot(rnorm(n), main = "the 1st plot")
        plot(hist(runif(n)), main = "the 2nd plot")

The basic idea is to use dev.set() function to set focus on different graphics devices. After one plot has been drawn, go to the next device to draw the next plot. That’s it.

Related Posts

To leave a comment for the author, please follow the link and comment on their blog: Statistics, R, Graphics and Fun » R Language.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , ,

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)