Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
| 2 | % Please edit documentation in R/mini_plots.R |
Bill Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 3 | \name{spec_plot} |
| 4 | \alias{spec_plot} |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 5 | \title{Helper functions to generate inline sparklines} |
| 6 | \usage{ |
Bill Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 7 | spec_plot( |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 8 | 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 Evans | a8ef1fb | 2020-09-12 22:55:46 -0700 | [diff] [blame] | 23 | pch = ".", |
Bill Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 24 | cex = 2, |
Bill Evans | a8ef1fb | 2020-09-12 22:55:46 -0700 | [diff] [blame] | 25 | type = "l", |
| 26 | polymin = NA, |
Bill Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 27 | minmax = list(pch = ".", cex = cex, col = "red"), |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 28 | min = minmax, |
| 29 | max = minmax, |
| 30 | dir = if (is_latex()) rmd_files_dir() else tempdir(), |
| 31 | file = NULL, |
Hao Zhu | 30db027 | 2021-02-19 13:02:29 -0500 | [diff] [blame] | 32 | file_type = if (is_latex()) "pdf" else svglite::svglite, |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 33 | ... |
| 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 |
| 46 | plotted 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 Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 61 | \item{frame.plot}{On/Off for surrounding box (\code{spec_plot} only). Default |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 62 | is False.} |
| 63 | |
Bill Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 64 | \item{lwd}{Line width for \code{spec_plot}; within \code{spec_plot}, the \code{minmax} |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 65 | argument defaults to use this value for \code{cex} for points. Default is 2.} |
| 66 | |
Bill Evans | a8ef1fb | 2020-09-12 22:55:46 -0700 | [diff] [blame] | 67 | \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 |
| 71 | not 'NA'.} |
| 72 | |
| 73 | \item{polymin}{Special argument that converts a "line" to a polygon, |
| 74 | where the flat portion is this value, and the other side of the polygon |
| 75 | is the 'y' value ('x' if no 'y' provided). If 'NA' (the default), then |
Bill Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 76 | this is ignored; otherwise if this is numeric then a polygon is |
| 77 | created (and 'type' is ignored). Note that if 'polymin' is in the middle |
| 78 | of the 'y' values, it will generate up/down polygons around this value.} |
Bill Evans | a8ef1fb | 2020-09-12 22:55:46 -0700 | [diff] [blame] | 79 | |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 80 | \item{minmax, min, max}{Arguments passed to \code{points} to highlight minimum |
Bill Evans | 548d715 | 2020-09-13 21:44:24 -0700 | [diff] [blame] | 81 | and maximum values in \code{spec_plot}. If \code{min} or \code{max} are \code{NULL}, they |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 82 | default 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 Evans | b62414a | 2020-09-14 12:33:38 -0700 | [diff] [blame] | 88 | \item{file_type}{Graphic device. Can be character (e.g., \code{"pdf"}) |
| 89 | or a graphics device function (\code{grDevices::pdf}). This defaults |
| 90 | to \code{"pdf"} if the rendering is in LaTeX and \code{"svg"} otherwise.} |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 91 | |
| 92 | \item{...}{extra parameters passing to \code{plot}} |
| 93 | } |
| 94 | \description{ |
| 95 | These functions helps you quickly generate sets of sparkline |
| 96 | style plots using base R plotting system. Currently, we support histogram, |
Hao Zhu | f6b60e8 | 2020-10-21 18:58:19 -0400 | [diff] [blame] | 97 | boxplot, line, scatter and pointrange plots. You can use them together with |
| 98 | \code{column_spec} to generate inline plot in tables. By default, this function |
| 99 | will save images in a folder called "kableExtra" and return the address of |
| 100 | the file. |
Hao Zhu | defd189 | 2020-09-09 00:08:09 -0400 | [diff] [blame] | 101 | } |