blob: 829bae8439f330f24b3b42a8c8e3d73675019b4d [file] [log] [blame]
Hao Zhudefd1892020-09-09 00:08:09 -04001% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/mini_plots.R
Bill Evans548d7152020-09-13 21:44:24 -07003\name{spec_plot}
4\alias{spec_plot}
Hao Zhudefd1892020-09-09 00:08:09 -04005\title{Helper functions to generate inline sparklines}
6\usage{
Bill Evans548d7152020-09-13 21:44:24 -07007spec_plot(
Hao Zhudefd1892020-09-09 00:08:09 -04008 x,
9 y = NULL,
10 width = 200,
11 height = 50,
12 res = 300,
13 same_lim = TRUE,
14 xlim = NULL,
15 ylim = NULL,
16 xaxt = "n",
17 yaxt = "n",
18 ann = FALSE,
19 col = "lightgray",
20 border = NULL,
21 frame.plot = FALSE,
22 lwd = 2,
Bill Evansa8ef1fb2020-09-12 22:55:46 -070023 pch = ".",
Bill Evans548d7152020-09-13 21:44:24 -070024 cex = 2,
Bill Evansa8ef1fb2020-09-12 22:55:46 -070025 type = "l",
26 polymin = NA,
Bill Evans548d7152020-09-13 21:44:24 -070027 minmax = list(pch = ".", cex = cex, col = "red"),
Hao Zhudefd1892020-09-09 00:08:09 -040028 min = minmax,
29 max = minmax,
30 dir = if (is_latex()) rmd_files_dir() else tempdir(),
31 file = NULL,
Bill Evansb62414a2020-09-14 12:33:38 -070032 file_type = if (is_latex()) "pdf" else "svg",
Hao Zhudefd1892020-09-09 00:08:09 -040033 ...
34)
35}
36\arguments{
37\item{x, y}{Vector of values or List of vectors of values. y is optional.}
38
39\item{width}{The width of the plot in pixel}
40
41\item{height}{The height of the plot in pixel}
42
43\item{res}{The resolution of the plot. Default is 300.}
44
45\item{same_lim}{T/F. If x is a list of vectors, should all the plots be
46plotted in the same range? Default is True.}
47
48\item{xlim, ylim}{Manually specify plotting range in the form of
49\code{c(0, 10)}.}
50
51\item{xaxt}{On/Off for xaxis text}
52
53\item{yaxt}{On/Off for yaxis text}
54
55\item{ann}{On/Off for annotations (titles and axis titles)}
56
57\item{col}{Color for the fill of the histogram bar/boxplot box.}
58
59\item{border}{Color for the border.}
60
Bill Evans548d7152020-09-13 21:44:24 -070061\item{frame.plot}{On/Off for surrounding box (\code{spec_plot} only). Default
Hao Zhudefd1892020-09-09 00:08:09 -040062is False.}
63
Bill Evans548d7152020-09-13 21:44:24 -070064\item{lwd}{Line width for \code{spec_plot}; within \code{spec_plot}, the \code{minmax}
Hao Zhudefd1892020-09-09 00:08:09 -040065argument defaults to use this value for \code{cex} for points. Default is 2.}
66
Bill Evansa8ef1fb2020-09-12 22:55:46 -070067\item{pch, cex}{Shape and size for points (if type is other than "l").}
68
69\item{type}{Passed to \code{plot}, often one of "l", "p", or "b", see
70\code{\link[graphics:plot.default]{graphics::plot.default()}} for more details. Ignored when 'polymin' is
71not 'NA'.}
72
73\item{polymin}{Special argument that converts a "line" to a polygon,
74where the flat portion is this value, and the other side of the polygon
75is the 'y' value ('x' if no 'y' provided). If 'NA' (the default), then
Bill Evans548d7152020-09-13 21:44:24 -070076this is ignored; otherwise if this is numeric then a polygon is
77created (and 'type' is ignored). Note that if 'polymin' is in the middle
78of the 'y' values, it will generate up/down polygons around this value.}
Bill Evansa8ef1fb2020-09-12 22:55:46 -070079
Hao Zhudefd1892020-09-09 00:08:09 -040080\item{minmax, min, max}{Arguments passed to \code{points} to highlight minimum
Bill Evans548d7152020-09-13 21:44:24 -070081and maximum values in \code{spec_plot}. If \code{min} or \code{max} are \code{NULL}, they
Hao Zhudefd1892020-09-09 00:08:09 -040082default to the value of \code{minmax}. Set to an empty \code{list()} to disable.}
83
84\item{dir}{Directory of where the images will be saved.}
85
86\item{file}{File name. If not provided, a random name will be used}
87
Bill Evansb62414a2020-09-14 12:33:38 -070088\item{file_type}{Graphic device. Can be character (e.g., \code{"pdf"})
89or a graphics device function (\code{grDevices::pdf}). This defaults
90to \code{"pdf"} if the rendering is in LaTeX and \code{"svg"} otherwise.}
Hao Zhudefd1892020-09-09 00:08:09 -040091
92\item{...}{extra parameters passing to \code{plot}}
93}
94\description{
95These functions helps you quickly generate sets of sparkline
96style plots using base R plotting system. Currently, we support histogram,
97boxplot, and line. You can use them together with \code{column_spec} to
98generate inline plot in tables. By default, this function will save images
99in a folder called "kableExtra" and return the address of the file.
100}