plot_bar: Plot bar graph

View source: R/graphics.R

plot_barR Documentation

Plot bar graph

Description

Draw a simple bar chart from a two‑column data.frame: first column as categories (x), second as values.

Usage

plot_bar(data, label_x = "", label_y = "", colors = NULL, alpha = 1)

Arguments

data

two‑column data.frame: category in the first column, numeric values in the second

label_x

x‑axis label

label_y

y‑axis label

colors

optional fill color (single value)

alpha

bar transparency (0–1)

Details

If colors is provided, a constant fill is used; otherwise ggplot2's default palette applies. alpha controls bar transparency. The first column is coerced to factor when needed.

Value

returns a ggplot2::ggplot graphic

Examples

#summarizing iris dataset
data <- iris |> dplyr::group_by(Species) |>
dplyr::summarize(Sepal.Length=mean(Sepal.Length))
head(data)

# plotting data
grf <- plot_bar(data, colors="blue")
plot(grf)

daltoolbox documentation built on Nov. 5, 2025, 7:09 p.m.