plot_events_single: Plot Events as Bars

View source: R/plot_events.R

plot_events_singleR Documentation

Plot Events as Bars

Description

Plots event table columns as vertical bars.

Usage

plot_events_single(
  e,
  cols,
  xlim = NULL,
  ylim = NULL,
  xticks = NULL,
  yticks = NULL,
  xtick.labels = NULL,
  ytick.labels = NULL,
  main = NA,
  xlab = NA,
  ylab = NA,
  plot.grid = FALSE,
  sigfigs = c(3, 3),
  col = grDevices::grey.colors(length(cols)),
  border = par("fg"),
  lty = par("lty"),
  lwd = par("lwd"),
  xpd = FALSE,
  ...
)

Arguments

e

An event table.

cols

Names or indices of the event table columns to plot together as stacked bars.

xlim, ylim

Limits for the x and y axes. If NULL, limits are set to the range of the data and the y limits extended as needed to include 0.

xticks, yticks

The values to label on the x and y axes. If NULL, only the min and max x and y are labeled (and 0 as needed for y). If axTicks, the function will be used to generate R default tick marks.

xtick.labels, ytick.labels

Labels for the x and y tick positions.

main

An overall title for the plot.

xlab, ylab

Titles for the x and y axes.

plot.grid

If TRUE, a lined horizontal grid is plotted at the yticks.

sigfigs

The maximum significant figures to use for the x and y axis labels.

col

Color(s) for the bars. If NULL, bars are transparent. By default, a grey palette is used.

border

Color(s) for bar borders. Use border = NA to omit borders.

lty

Line type(s) for bar borders.

lwd

Line width(s) for bar borders.

xpd

Logical value or NA. If FALSE, all plotting is clipped to the plot region, if TRUE, all plotting is clipped to the figure region, and if NA, all plotting is clipped to the device region.

...

Additional arguments passed to plot.

Details

The specified event table columns are plotted together as stacked bars. Negative and positive values are stacked separately from the y = 0 baseline. Events with NA are not shown, differentiating them from zero-valued events which are drawn as thin black lines. Point events are drawn as thin vertical lines. Overlapping events are drawn as overlapping bars, so it is best to use sample_events with non-overlapping bins to flatten the data before plotting, then call this function for each bin group (if using multiple bin groups).

See Also

plot_events.

Examples

e <- events(from = c(0, 10, 15, 25), to = c(10, 20, 25, 40), length = c(10, 10, 10, 15),
            x = c(1, 2, 1, 1), f = c('a', 'b', 'a', 'a'))
bins <- seq_events(event_coverage(e), c(8, 4, 2, 1))
e.bins <- sample_events(e, bins, list(sum, c('x', 'length')), scaled.cols = 'length')
plot_events_single(e.bins[e.bins$group == 1, ], cols = 'x')

ezwelty/linbin documentation built on April 19, 2023, 8:41 a.m.