Description Usage Arguments Details Value References See Also Examples
mypdf
is a wrapper for pdf
from the
grDevices package. The difference is that
mypdf
determines the width and the height of the
plotting region from a given standard paper format using
paper_size
. max_rgb_constrast
is a helper
functions for arranging colours.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | mypdf(file, ...)
## S3 method for class 'character'
mypdf(file, paper = "a4r",
prop = 0.9, ...)
paper_size(x, ...)
## S3 method for class 'numeric'
paper_size(x, landscape = FALSE,
series = c("A", "B", "C"), ...)
## S3 method for class 'character'
paper_size(x, landscape = FALSE,
inches = FALSE, ...)
max_rgb_contrast(x, ...)
## Default S3 method:
max_rgb_contrast(x, ...)
|
file |
Passed as ‘file’ argument to
|
paper |
Character scalar like the eponymous argument
of |
prop |
Numeric vector. Its values should be between
0 and 1. Its first element is multiplied with the width
of |
x |
Numeric or character vector for determining the paper size. If a numeric vector, specifying paper sizes in the ‘DIN’ series. If a character vector, the full names of well-known paper formats such as ‘a4’, ‘letter’, etc. For |
landscape |
Logical scalar. If |
inches |
Logical scalar. If |
series |
Character scalar indicating the ‘DIN’ series to assume. |
... |
Optional arguments passed to other methods,
e.g., to |
The computation of the paper size is done numerically for the DIN series, whereas a look-up table is used for the other formats.
max_rgb_contrast
arranges colours so as to achieve
that neighbouring colours are most distinct with respect
to their RGB coordinates. This is done as
follows: (1) Euclidean distances between the
RGB coordinates of the input colours are
calculated; (2) the distances are log-transformed and
inverted; (3) a principal-coordinate analysis is
conducted on these inverted distances; (4) the input
colours are sorted according to the first principal
coordinate.
Note that this is probably only works for colour vectors of small to moderate size, and that the resulting vector could as well be used in reverse order (see the examples).
mypdf
returns NULL
. As a side effect,
file
is opened. paper_size
yields a numeric
matrix with columns ‘width’ and ‘height’
and x
as row names (if it was a character vector).
max_rgb_contrast
returns a character vector (the
rearranged input names).
https://en.wikipedia.org/wiki/Paper_size
grDevices::pdf grDevices::col2rg
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 26 27 28 29 30 31 32 | ## Not run:
mypdf("example.pdf")
## create some plots...
dev.off()
## End(Not run)
## paper_size()
query <- c("A4", "Letter", "unknown")
(x <- paper_size(query))
stopifnot(is.matrix(x), is.numeric(x), rownames(x) == query)
stopifnot(colnames(x) == c("height", "width"), is.na(x["unknown", ]))
(y <- paper_size(4))
stopifnot(identical(y, x[1L, , drop = FALSE]))
## max_rgb_contrast()
# with colours
(x <- max_rgb_contrast(c("darkred", "darkblue", "blue", "red")))
y <- c("darkblue", "red", "blue", "darkred")
stopifnot(identical(x, y) || identical(x, rev(y)))
# shades of grey 1
(x <- max_rgb_contrast(c("white", "grey", "black")))
y <- c("grey", "black", "white")
stopifnot(identical(x, y) || identical(x, rev(y)))
# shades of grey 2
(x <- max_rgb_contrast(c("white", "darkgrey", "lightgrey", "black")))
y <- c("lightgrey", "black", "white", "darkgrey")
stopifnot(identical(x, y) || identical(x, rev(y)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.