pyramid_chart: Pyramid Chart

Description Usage Arguments Value Author(s) Examples

View source: R/pyramid_chart.R

Description

Easily create a pyramid chart

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
pyramid_chart(
  data,
  x,
  y,
  group,
  bar_colors = c("#1F77B4", "#FF7F0E"),
  sort = "no",
  xlab = NULL,
  title = NULL
)

Arguments

data

Dataset to use for the pyramid chart

x

character or factor column of data

y

numeric column of data

group

character or factor column of data

bar_colors

character vector of length 2 containing colors

sort

character. Should the bars be sorted? By default "no".

xlab

character. X axis label

title

character. Plot title. By default no title is displayed.

Value

An object of class ggplot

Author(s)

Thomas Neitmann

Examples

1
2
3
4
5
6
7
8
9
data(popch)

pyramid_chart(popch, age, pop, sex)

## Change bar colors
pyramid_chart(popch, age, pop, sex, bar_colors = c("darkgreen", "darkorange"))

## Change x axis label and add title
pyramid_chart(popch, age, pop, sex, xlab = "Population", title = "Switzerland 2020")

thomas-neitmann/ggcharts documentation built on Oct. 8, 2021, 1:17 a.m.