Skip to contents

This function creates a horizontal stacked bar chart in plotly with bar labels displaying category labels, values, and percentages.

Usage

BC_h(cat_labels, values, colors, title = "", rev = FALSE)

Arguments

cat_labels

a character vector of category labels for the bars.

values

a numeric vector of values for each category.

colors

a character vector of colors for each category.

title

The title of the plot.

rev

Should the order of categories be reversed?

Value

a plotly object of the stacked bar chart.

Examples

BC_h(
  cat_labels=c("Yes", "No", "not applicable"),
  values=c(10, 2, 4),
  colors=c("#90c916", "#FED976", "#eeeeee"),
  title="The publication contained a preregistered replication attempt")
BC_h( cat_labels=c("Yes", "No"), values=c(10, 2), colors=c("#90c916", "#FED976"))
BC_h(cat_labels=c("Yes"), values=c(10), colors=c("#90c916"))