Skip to contents

Draw bar chart.

Usage

draw_bar(
  values,
  cates = NULL,
  axis = NULL,
  groups = length(values),
  bar_side = 1,
  bar_way = 1,
  gap = ifelse(side_label == 1, 0.6, 0.1),
  csize = 0.8,
  space = 0.9,
  adj = -0.01,
  gl = TRUE,
  label = c("Male", "Female"),
  cols = c("#006400", "#b32134"),
  side_label = 1,
  legend = FALSE,
  legend_label = NULL,
  dens = c(-1, -1),
  overlay = FALSE,
  ...
)

Arguments

values

List of values to be draw.

cates

Categories for the groups.

axis

Axis values.

groups

Groups of the bar chart, default is length of the values list.

bar_side

Orientation of the bar chart: 1 for left and 2 for right.

bar_way

Draw the bar chart unidirectionally or bidirectionally, 1 for unidirectionally and 2 for bidirectionally.

gap

The width of center gap. Default is 0.1.

csize

The font size to write the labels on sides. Default is 1.

space

Space between bars.

adj

The vertical adjustment factor for the labels of age classes. Default is -0.01.

gl

Logical value to draw the vertical dotted lines. Default is TRUE.

label

Labels for the two sides.

cols

The colors of the bars.

side_label

Draw the side label on the left or right. 1 for left and 2 for right.

legend

Logical value indicates plot legend or not.

legend_label

Character for the legend label.

dens

The density of hatching lines (/inch).

overlay

Logical value, TRUE for overlay plot, FALSE for not.

...

Other options.

Value

A bar chart.