View source: R/mk_mountrange.R
mk_mountrange | R Documentation |
mk_mountrange
takes a data frame as input and returns a function for
making a set of density plots of any continuous variable (x) from the data
frame for each level of a categorical variable (y).
mk_mountrange(df)
df |
A data frame. |
function(xvar, yvar = "1", fillby = '..x..', cut_tail = 0.005,
scale_height = 1, font_size = 14)
xvar. String, name of a continuous variable for x-axis.
yvar. String, name of a categorical variable for y-axis. It's used to group x. Default is "1", meaning no groups.
fillby. String, name of the statistic for filling the space under the density curves. Possible values are 'x' (default), 'density' (pdf), 'ndensity' (normalized pdf with max = 1), and 'ecdf'.
cut_tail. A number between 0 and 1. Lines with heights below this cutoff will be removed. The cutoff is relative to the overall maximum, so cut_tail = 0.01 would remove everything that is 1 percent or less than the highest point. Default = 0.005, so 0.5 percent or less are removed.
scale_height. Number, default = 3. scale_height=1 means the tallest density curve just touches the baseline of the next higher one. Smaller values create a separation between the curves, and larger values create more overlap.
color_direction. 1 or -1. Sets the order of colors. If 1 (default), colors are ordered from darkest to lightest. If -1, ordered from lightest to darkest.
hue. A string indicating the colormap option to use. Four options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" (or "C", the default option), "viridis" (or "D") and "cividis" (or "E"). Usually, you want to use "C" (reddish warm/hot) or 'D' (greenish cool/cold).
font_size. Overall font size. Default = 14. The font size of the axes and legend text is a fraction of this value.
inst/examples/ex-mk_mountrange.R
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.