mk_lollipop | R Documentation |
mk_lollipop
takes a data frame as input and returns a function
for making horizontal lollipop charts with any categorical variable from the
data frame on y-axis and the value (or cumulative values) of any continuous
variable on x-axis. The resulting chart will have the y levels ordered
alphanumerically by default. It'll label the stems of lollipops with the
cumulative x values. If the x values are decimals, user can specify the
number of decimals to display. If the x values are between 0 and 1,
user can choose to format the x-axis and the labels as percent (
the resulting plot will have a clean theme and clear fonts.
It'll also use color-blind friendly palettes.
mk_lollipop(df)
df |
A data frame. |
function(xvar, yvar, yorder = "alphanumeric", show_pct = FALSE,
label_decimals = 1, label_size = 3, font_size = 14)
xvar. String, name of a continuous variable for x-axis.
yvar. String, name of a categorical variable for y-axis.
yorder. String, "alphanumeric", "ascend" or "descend". It specifies how categories are ordered on the y-axis. Default = "alphanumeric".
show_pct. Logical, if TRUE, format x-axis and bar labels as otherwise, format them as comma. Default is FALSE.
label_decimals. Integer, the number of decimal points shown on the bar labels. Default = 1.
label_size. Integer, size of bar label text. Default = 3. Hide bar labels when its value is 0.
font_size. Overall font size. Default = 14. The font size of the axes and legend text is a fraction of this value.
scale_axis
for adding different scales to the y-axis.
inst/examples/ex-mk_lollipop.R
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.