| devsize.default {plotscale} | R Documentation |
Determine Device Size by Default
Description
Determines smallest device width and height that give a plot width
and height at least as large as the supplied width and height.
Plot width and height are determined by plotsize (e.g., by the dimensions
of the first panel as for plotsize.default).
Usage
## Default S3 method:
devsize(x, width, height, device = list(width = width * 1.1,
height = height * 1.1), digits = getOption("plotscale_devsize_digits", 2),
plotsize = getOption("plotscale_plotsize", "plotsize"),
width.major = TRUE, optimize.minor = TRUE, check.aspect = TRUE,
verbose = getOption("plotsize_verbose", FALSE), ...)
Arguments
x |
object |
width |
desired plot width in inches |
height |
desired plot height in inches |
device |
length 2 named list suggesting initial width and height for device |
digits |
|
plotsize |
a function of x, width, height, digits and ... that returns a named list with elements 'width' and 'height' giving dimensions of x |
width.major |
whether to optimize width first for fixed aspect plots (used internally) |
optimize.minor |
whether to minor dimension for fixed aspect plots (used internally) |
check.aspect |
whether to adjust width and height to conform to fixed aspect (used internally) |
verbose |
whether to explain the process |
... |
other arguments passed to fun |
Value
length 2 named list giving device width and height in inches (class 'size')
See Also
Other devsize: as.size,
devsize, print.size,
unscaled.default, unscaled
Examples
options(example.ask = FALSE)
options(device.ask.default = FALSE)
library(lattice)
data(iris)
x <- xyplot(Petal.Width~Petal.Length, groups = Species, data = iris)
devsize(x, width = 4, height = 4, digits = 1, verbose = TRUE)
devsize(x, width = 4, height = 5, digits = 1, verbose = TRUE)
x <- update(x, aspect = 1)
devsize(x, width = 4, height = 4, digits = 1, verbose = TRUE)
devsize(x, width = 4, height = 5, digits = 1, verbose = TRUE)
devsize(splom(iris[,1:4]), width = 4, height = 4)
devsize(xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris), width = 4, height = 4)
library(ggplot2)
p <- ggplot(data = iris, mapping = aes(y = Sepal.Length, x = Sepal.Width)) +
geom_point() + facet_wrap(~Species)
devsize(p, width = 4, height = 4)
devsize(p + theme(aspect.ratio = 1), width = 4, height = 4)