manual_brush: Manually brush the plot via command line

Description Usage Arguments Value Author(s) Examples

View source: R/brush.R

Description

We can brush a plot via command line rather than using the mouse.

Usage

1
manual_brush(obj, pos, pause = 0)

Arguments

obj

the plot object with an attribute meta, e.g. returned by qbar

pos

the mouse position(s); can be a numeric vector of length 2 or a matrix of 2 columns with each row representing a mouse position

pause

the time to pause between two successive mouse positions (recycled to the same length of pos; each element used after each mouse position)

Value

NULL

Author(s)

Yihui Xie <http://yihui.name>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
library(cranvas)
qnrc <- qdata(nrcstat, color = RegCode)
(o1 <- qbar(RegCode, qnrc))
(o2 <- qparallel(vars = 13:10, data = qnrc, main = "Overview of Rankings", 
    glyph = "tick", horizontal = FALSE, boxplot = TRUE))

## automatically brush the bar plot
brush(qnrc, "style")$color <- "brown"
l <- attr(o1, "meta")$limits
# interpolate some random positions
p <- approx(runif(50, l[1, 1], l[2, 1]), runif(50, l[1, 2], l[2, 2]), 
    n = 500)
manual_brush(o1, cbind(p$x, p$y), pause = if (interactive()) 0.1 else 0)

## can also brush the par-coords plot
manual_brush(o2, as.matrix(expand.grid(seq(0, 1, 0.1), (1:4) - 0.1)), 
    pause = if (interactive()) 0.2 else 0)

cranvas_off()

ggobi/cranvas documentation built on May 17, 2019, 3:10 a.m.