Learn R Programming

daltoolbox (version 1.2.747)

plot_pieplot: Plot pie

Description

Pie chart from a two‑column data.frame (category, value) using polar coordinates.

Usage

plot_pieplot(
  data,
  label_x = "",
  label_y = "",
  colors = NULL,
  textcolor = "white",
  bordercolor = "black"
)

Value

returns a ggplot2::ggplot graphic

Arguments

data

two‑column data.frame with category and value

label_x

x‑axis label (unused in pie, kept for symmetry)

label_y

y‑axis label (unused in pie)

colors

vector of slice fills

textcolor

label text color

bordercolor

slice border color

Details

Slices are sized by the second (numeric) column. Text and border colors can be customized.

Examples

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

#ploting data
grf <- plot_pieplot(data, colors=c("red", "green", "blue"))
plot(grf)

Run the code above in your browser using DataLab