Description Usage Arguments Details Value Note Author(s) See Also Examples
This function is similar to mtext
, which
draws text into the margin of a plot. A slight difference is this
function creates a layer which can be put anywhere in the layout.
We can also create a title layer with this function.
1 2 |
parent |
the parent layer (default to be |
meta |
|
side |
which side to draw the text (following the convention
of R base graphics); e.g. |
text |
the character string to draw; if |
x |
the x coordinate |
y |
the y coordinate |
cex |
the expansion factor |
... |
other arguments passed to |
As in R base graphics, the margin means the bottom, left, top and right area of the main plot region. This function will adjust the direction of the text according to the side to which it is drawn, e.g., the left or right side will make the text vertical.
a layer object
The limits of the text layer is [0, 1] both horizontally and vertically by default.
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 | library(cranvas)
library(qtbase)
library(qtpaint)
s <- qscene()
r <- qlayer(s) # root layer
m <- qlayer(paintFun = function(layer, painter) {
qdrawCircle(painter, runif(1000), runif(1000), r = 2)
qdrawRect(painter, 0, 0, 1, 1)
}, limits = qrect(matrix(c(0, 1, 0, 1), 2))) # main layer
m1 <- qmtext(text = "x axis title!", side = 1)
m2 <- qmtext(text = "y axis title!", side = 2)
m3 <- qmtext(text = "THE MAIN TITLE", side = 3)
m4 <- qmtext(text = "text on the right margin", side = 4)
## note how to arrange these layers appropriately in the margin
r[1, 1] <- m
r[2, 1] <- m1
r[1, 0] <- m2
r[0, 1] <- m3
r[1, 2] <- m4
print(qplotView(scene = s))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.