Debian Codegraph @

man/plot.units.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/plot.R
3 \name{plot.units}
4 \alias{plot.units}
5 \alias{make_unit_label}
6 \title{Plot \code{units} objects}
7 \usage{
8 make_unit_label(lab, u, sep = units_options("sep"),
9 group = units_options("group"), parse = units_options("parse"))
10
11 \method{plot}{units}(x, y, xlab = NULL, ylab = NULL, ...)
12 }
13 \arguments{
14 \item{lab}{length one character; name of the variable to plot}
15
16 \item{u}{vector of class \code{units}}
17
18 \item{sep}{length two character vector, defaulting to \code{c("~","~")}, with
19 the white space between unit name and unit symbols, and between subsequent
20 symbols.}
21
22 \item{group}{length two character vector with grouping symbols, e.g.
23 \code{c("(",")")} for parenthesis, or \code{c("","")} for no group symbols}
24
25 \item{parse}{logical; indicates whether a parseable expression should be
26 returned (typically needed for super scripts), or a simple character string
27 without special formatting.}
28
29 \item{x}{object of class units, to plot along the x axis, or, if y is missing, along the y axis}
30
31 \item{y}{object to plot along the y axis, or missing}
32
33 \item{xlab}{character; x axis label}
34
35 \item{ylab}{character; y axis label}
36
37 \item{...}{other parameters, passed on to \link{plot.default}}
38 }
39 \description{
40 Create axis label with appropriate labels.
41
42 Plot method for \code{units} objects.
43 }
44 \details{
45 \link{units_options} can be used to set and change the defaults for
46 \code{sep}, \code{group} and \code{doParse}.
47 }
48 \examples{
49 displacement = mtcars$disp * as_units("in")^3
50 units(displacement) = make_units(cm^3)
51 weight = mtcars$wt * 1000 * make_units(lb)
52 units(weight) = make_units(kg)
53 plot(weight, displacement)
54
55 units_options(group = c("(", ")") ) # parenthesis instead of square brackets
56 plot(weight, displacement)
57
58 units_options(sep = c("~~~", "~"), group = c("", "")) # no brackets; extra space
59 plot(weight, displacement)
60
61 units_options(sep = c("~", "~~"), group = c("[", "]"))
62 gallon = as_units("gallon")
63 consumption = mtcars$mpg * make_units(mi/gallon)
64 units(consumption) = make_units(km/l)
65 plot(displacement, consumption) # division in consumption
66
67 units_options(negative_power = TRUE) # division becomes ^-1
68 plot(displacement, consumption)
69
70 plot(1/displacement, 1/consumption)
71
72 }