init_barplot: custom barplots

Description Usage Arguments Functions Examples

View source: R/plots.R

Description

A custom barplot separated into one init function and two different barplot functions so it can easily be added to other plots or used in combination with points, lines and so on.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
init_barplot(
  x = names(y),
  y,
  xlim = NULL,
  ylim = NULL,
  include0 = TRUE,
  ylab = "",
  xlab = "",
  main = "barplot",
  las = 2
)

lines_barplot(x = names(y), y, lwd = 3, col = "black")

rect_barplot(x = names(y), y, width = 0.7, col = "black")

Arguments

x, y

double, for x also a character vector is allowed, if only one argument is provided it is taken as y and its names as x. If x can be converted to double it is used as x, if not it is only used as labels.

xlim, ylim

limits for both axes; if NULL they will be calculated by the function. if include0 == TRUE, ylim[1] will be overwritten with 0.

include0

logic, if TRUE y axis includes origin

ylab

a title for the y axis

xlab

a title for the x axis

main

an overall title for the plot

las

numeric, see par

lwd

line width as used in lines

col

bar color

width

specifies the box width (with = 1 leaves no space between the bars)

Functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- 10 + rnorm(40)
names(x) <- 1901:1940

# rect_barplot:
init_barplot(x)
rect_barplot(x, width = 0.5)

# lines_barplot:
init_barplot(x)
lines_barplot(x, lwd = 3)

konradmayer/trlboku documentation built on July 3, 2020, 9:49 p.m.