Add count
Usage
add_count_bar(
plot,
dodge_width = NULL,
width = 0.6,
saturation = 1,
preserve = "total",
...
)
add_count_dash(
plot,
dodge_width = NULL,
width = 0.6,
linewidth = 0.25,
preserve = "total",
...
)
add_count_dot(plot, dodge_width = NULL, size = 2, preserve = "total", ...)
add_count_value(
plot,
dodge_width = NULL,
accuracy = 0.1,
scale_cut = NULL,
fontsize = 7,
extra_padding = 0.15,
vjust = NULL,
hjust = NULL,
preserve = "total",
...
)
add_count_line(
plot,
group,
dodge_width = NULL,
linewidth = 0.25,
preserve = "total",
...
)
add_count_area(
plot,
group,
dodge_width = NULL,
linewidth = 0.25,
preserve = "total",
...
)
Arguments
- plot
A
tidyplot
generated with the functiontidyplot()
.- dodge_width
For adjusting the distance between grouped objects. Defaults to
0.8
for plots with at least one discrete axis and0
for plots with two continuous axes.- width
Width of the plot area. Defaults to
50
.- saturation
A
number
between0
and1
for the color saturation of an object. A value of0
is completely desaturated (white),1
is the original color.- preserve
Should dodging preserve the
"total"
width of all elements at a position, or the width of a"single"
element?- ...
Arguments passed on to the
geom
function.- linewidth
Thickness of the line in points (pt). Typical values range between
0.25
and1
.- size
A
number
representing the size of the plot symbol. Typical values range between1
and3
.- accuracy
A number to round to. Use (e.g.)
0.01
to show 2 decimal places of precision. IfNULL
, the default, uses a heuristic that should ensure breaks have the minimum number of digits needed to show the difference between adjacent values.Applied to rescaled data.
- scale_cut
Scale cut function to be applied. See
scales::cut_short_scale()
and friends.- fontsize
Font size in points. Defaults to
7
.- extra_padding
Extra padding to create space for the value label.
- vjust
Vertical position adjustment of the value label.
- hjust
Horizontal position adjustment of the value label.
- group
Variable in the dataset to be used for grouping.
Examples
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_bar()
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_dash()
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_dot()
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_value()
dinosaurs %>%
tidyplot(x = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_line()
dinosaurs %>%
tidyplot(x = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_area()
# Combination
dinosaurs %>%
tidyplot(x = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_bar(alpha = 0.4) %>%
add_count_dash() %>%
add_count_dot() %>%
add_count_value() %>%
add_count_line()
# Changing arguments: alpha
# Makes objects transparent
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
theme_minimal_y() %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_bar(alpha = 0.4)
# Changing arguments: saturation
# Reduces fill color saturation without making the object transparent
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
theme_minimal_y() %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_bar(saturation = 0.3)
# Changing arguments: accuracy
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_value(accuracy = 1)
# Changing arguments: fontsize
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_value(fontsize = 10)
# Changing arguments: color
dinosaurs %>%
tidyplot(x = time_lived, color = time_lived) %>%
adjust_x_axis(rotate_labels = TRUE) %>%
add_count_value(color = "black")