`lollipop()` is a simple lollipop chart (dots connected to the baseline by a segment) with some customization allowed. `hlollipop()` uses `lollipop()` with sane defaults for a horizontal lollipop chart.
Usage
hlollipop(..., flip = TRUE, theme_fun = theme_lollipop(flip = flip))
lollipop(
df,
x,
y,
group = "",
facet = "",
order = "y",
x_rm_na = TRUE,
y_rm_na = TRUE,
group_rm_na = TRUE,
facet_rm_na = TRUE,
y_expand = 0.1,
add_color = color("cat_5_main_1"),
add_color_guide = TRUE,
flip = FALSE,
wrap = NULL,
alpha = 1,
x_title = NULL,
y_title = NULL,
group_title = NULL,
title = NULL,
subtitle = NULL,
caption = NULL,
dot_size = 4,
line_size = 0.8,
line_color = color("dark_grey"),
dodge_width = 0.9,
theme_fun = theme_lollipop(flip = flip, axis_text_x_angle = 0, axis_text_x_vjust = 0.5,
axis_text_x_hjust = 0.5),
scale_fill_fun = scale_fill_visualizer_discrete(),
scale_color_fun = scale_color_visualizer_discrete()
)
Arguments
- ...
Additional arguments passed to `lollipop()`
- flip
TRUE or FALSE (default). Default to TRUE or horizontal lollipop plot.
- theme_fun
Whatever theme function. For no custom theme, use theme_fun = NULL.
- df
A data frame.
- x
A quoted character column or coercible as a character column.
- y
A quoted numeric column.
- group
Some quoted grouping categorical column, e.g. administrative areas or population groups.
- facet
Some quoted grouping categorical column, e.g. administrative areas or population groups.
- order
A character scalar specifying the order type (one of "none", "y", "grouped"). See details.
- x_rm_na
Remove NAs in x?
- y_rm_na
Remove NAs in y?
- group_rm_na
Remove NAs in group?
- facet_rm_na
Remove NAs in facet?
- y_expand
Multiplier to expand the y axis.
- add_color
Add a color to dots (if no grouping).
- add_color_guide
Should a legend be added?
- wrap
Should x-labels be wrapped? Number of characters.
- alpha
Fill transparency for dots.
- x_title
The x scale title. Default to NULL.
- y_title
The y scale title. Default to NULL.
- group_title
The group legend title. Default to NULL.
- title
Plot title. Default to NULL.
- subtitle
Plot subtitle. Default to NULL.
- caption
Plot caption. Default to NULL.
- dot_size
The size of the dots.
- line_size
The size/width of the line connecting dots to the baseline.
- line_color
The color of the line connecting dots to the baseline.
- dodge_width
Width for position dodge when using groups (controls space between grouped lollipops).
- scale_fill_fun
Scale fill function. Default to scale_fill_visualizer_discrete().
- scale_color_fun
Scale color function. Default to scale_color_visualizer_discrete().
Examples
if (FALSE) { # \dontrun{
df <- data.frame(x = letters[1:5], y = c(10, 5, 7, 12, 8))
# Vertical lollipop
lollipop(df, "x", "y")
# Horizontal lollipop
hlollipop(df, "x", "y")
} # }