cranvas (version 0.8.5)

qgrid: Create a background grid layer

Description

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

Usage

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

See Also

grid, qlayer

Examples

Run this code
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))

Run the code above in your browser using DataLab