devsize.default: Determine Device Size by Default

Description Usage Arguments Value See Also Examples

View source: R/default.R

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

1
2
3
4
5
6
## 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

round width, height, device, and result to this many decimal places; passed to plotsize

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)

plotscale documentation built on May 2, 2019, 6:50 a.m.