bar_plot | R Documentation |
bar_plot
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"),
rescale_y = 1.1,
label_cutoff = 0.12,
use_theme = theme_ez,
position = "stack",
facet_scales = "fixed",
legend_ncol = NULL,
coord_flip = FALSE
)
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". |
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() |
A ggplot object.
library(tsibble)
library(tsibbledata)
library(lubridate)
bar_plot(ansett, "year(Week)", "Passengers", size = 16, rescale_y = 1.5)
bar_plot(ansett, "year(Week)", "Passengers", "Class")
bar_plot(ansett, "Airports", c("Share of Passengers" = "Passengers"), "Class", position = "fill")
bar_plot(ansett, "Airports", "Passengers", "Class", reorder = NULL, label_pos = "both")
bar_plot(ansett, "Airports",
c(Passengers = "ifelse(Class == 'Economy', Passengers, -Passengers)"),
"Class", label_pos = "both")
bar_plot(ansett, "year(Week)", "Passengers", "Class", label_pos = "both", coord_flip = TRUE)
bar_plot(mtcars, "factor(cyl)", "1", "am", position = "dodge")
bar_plot(mtcars, "factor(cyl)", "1", "am", position = "dodge", coord_flip = TRUE)
bar_plot(mtcars, "factor(cyl)", "1", "am", position = "dodge", coord_flip = TRUE, rescale_y = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.