bar_plot {ezplot} | R Documentation |
bar_plot
Description
bar_plot
Usage
bar_plot(
data,
x,
y = "1",
group = NULL,
facet_x = NULL,
facet_y = NULL,
size = 11,
width = NULL,
reorder = c("group", "facet_x", "facet_y"),
palette = ez_col,
labels_y = if (position == "fill") {
function(x) ez_labels(100 * x, append =
"%")
} else {
ez_labels
},
labels_x = identity,
label_pos = c("auto", "inside", "top", "both", "none"),
label_inside = c("y", "absolute", "share", "percent", "both"),
rescale_y = 1.1,
label_cutoff = 0.12,
use_theme = theme_ez,
position = "stack",
facet_scales = "fixed",
legend_ncol = NULL,
coord_flip = FALSE,
angle = 0,
repel = FALSE
)
Arguments
data |
A data.frame. |
x |
A named character value. Evaluates to a column. |
y |
A named character value. Evaluates to a column. |
group |
A character value. Evaluates to a column. |
facet_x |
A character value. Evaluates to a column. |
facet_y |
A character. Evaluates to a column. |
size |
theme size for |
width |
Width of bar. |
reorder |
A character vector specifying the group variables to reorder.
Default is |
palette |
Colour function. |
labels_y |
label formatting function |
labels_x |
label formatting function |
label_pos |
Position of labels. Can be "auto", "inside", "top", "both" or "none". |
label_inside |
Value to display inside bar segments. Options are "y", "absolute", "percent", "share" or "both". |
rescale_y |
Rescaling factor for y-axis limits |
label_cutoff |
Cutoff size (proportion of y data range) for excluding labels |
use_theme |
ggplot theme function |
position |
Either |
facet_scales |
Option passed to scales argument in |
legend_ncol |
Number of columns in legend. |
coord_flip |
logical (default is FALSE). If TRUE, flips the x and y coordinate using ggplot2::coord_flip() |
angle |
angle for geom_text(_repel) |
repel |
logical (default if FALSE). If TRUE, uses ggrepel for geom_text |
Value
A ggplot object.
Examples
library(tsibble)
library(tsibbledata)
library(lubridate)
bar_plot(ansett, "year(Week)", "Passengers")
bar_plot(ansett, "year(Week)", "Passengers", "Class", label_pos = "both")
bar_plot(ansett, "year(Week)", "Passengers", "Class", label_pos = "both", label_inside = "both")
bar_plot(ansett, "year(Week)", "Passengers", "Class", coord_flip = TRUE)