Description Usage Arguments Value Note Author(s) See Also Examples
This function creates an axis layer which contains tick marks and labels at given locations.
1 |
parent |
the parent layer (default to be |
meta |
|
side |
which side to draw the axis (following the convention
of R base graphics, i.e., 1: bottom, 2: left, 3: top, 4: right);
the location of tick marks and labels will automatically adjusted
according |
at |
the locations of tick marks |
labels |
the labels of the tick marks |
... |
other arguments passed to |
a layer object
The vertical range of the x-axis is [0, 1], and the horizontal limit of y-axis is [0, 1].
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 axis layer will sync
with meta$limits
dynamically.
Yihui Xie <http://yihui.name>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | library(cranvas)
library(qtpaint)
s <- qscene()
r <- qlayer(s)
r[1, 1] <- qlayer(paintFun = function(layer, painter) {
qdrawCircle(painter, runif(1000, 0, 10), runif(1000, -5, 3), r = 2)
qdrawRect(painter, 0, -5, 10, 3)
}, limits = qrect(c(0, 10), c(-5, 3))) # main layer
## note the vertical limits of x-axis and horizontal limits of y-axis are [0, 1]
#' x-axis
r[2, 1] <- qaxis(side = 1, at = c(0, 1, 3, 7, 8), limits = qrect(c(0, 10), c(0, 1)))
#' y-axis
r[1, 0] <- qaxis(side = 2, at = c(-4.5, -1, 0, 1.5, 2.5), limits = qrect(c(0, 1),
c(-5, 3)))
#' top x-axis
r[0, 1] <- qaxis(side = 3, meta = list(xat = c(1, 3, 7), xlabels = c("a", "b", "c"),
limits = matrix(c(0, 10, -5, 3), 2)))
fix_dimension(r, row = list(id = c(0, 2), value = c(30, 30)), column = list(id = 0,
value = 30))
qplotView(scene = s)
cranvas_off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.