qgrid: Create a background grid layer

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/axes.R

Description

A layer with gray background and white grid lines corresponding to axis tick marks. Minor grid lines are optional and thinner.

Usage

1
qgrid(parent = NULL, meta = NULL, xat, yat, xlim, ylim, minor = "xy", ...)

Arguments

parent

the parent layer (default to be NULL, which means creating an independent layer with no parents, but it can be added to a parent layer using the approach parent[i, j] <- child_layer)

meta

NULL means to use xat, yat, otherwise it should be an object containing child elements xat and yat, and it will override the next two arguments; besides, the limits of the layer will be set to meta$limits so this element should be present as well

xat

locations to draw vertical grid lines

yat

locations to draw horizontal grid lines

xlim

the x-axis limits (c(x0, x1))

ylim

the y-axis limits (c(y0, y1))

minor

defines which minor lines to draw: 'x': only on the x-axis; 'y': only on the y-axis; 'xy': both x and y minor grid lines; '': no minor grid lines

...

other arguments passed to qlayer

Value

a layer object

Note

If meta is not NULL, it is supposed to be a reference object, and an event will be attached on meta$limits so that the limits of the grid layer will sync with meta$limits dynamically.

Author(s)

Yihui Xie <http://yihui.name>

See Also

grid, qlayer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(cranvas)
library(qtbase)
library(qtpaint)

s <- qscene()
r <- qlayer(s)
l <- qrect(matrix(c(0, 1, 0, 1), 2))
m <- qlayer(paintFun = function(layer, painter) {
    qdrawCircle(painter, runif(1000), runif(1000), r = 2)
    qdrawRect(painter, 0, 0, 1, 1)
}, limits = l)  # main layer
g <- qgrid(xat = seq(0, 1, 0.2), yat = seq(0, 1, 0.5), xlim = c(0, 1), ylim = c(0, 
    1), limits = l)
r[1, 1] <- g  # must add the grid layer FIRST, then the plot layer
r[1, 1] <- m
print(qplotView(scene = s))

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