timeline: Creates a timeline plot.

Description Usage Arguments Examples

View source: R/timeline.R

Description

This function will create a timeline using the ggplot2 framework in a style similar to Preceden. There are two types of events, those that have a range (i.e. a start and end date) and and points-in-time. The latter can be grouped in separate rows to prevent overlapping or to organize different types of events. Grouping of point-in-time events will color code those events accordingly.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
  timeline(df, events, label.col = names(df)[1],
    group.col = names(df)[2], start.col = names(df)[3],
    end.col = names(df)[4],
    text.position = c("left", "right", "center"),
    text.size = 4, text.color = "black", text.alpha = 1,
    text.angle = 0, text.family = "serif",
    text.fontface = 1, text.hjust, text.vjust = 0.5,
    text.lineheight = 1, num.label.steps = 5,
    event.label.col, event.col, event.group.col,
    event.spots = 1, event.label = "",
    event.label.method = 1, event.line = FALSE,
    event.text.size = 4, event.text.color = "black",
    event.text.alpha = 1, event.text.angle = 0,
    event.text.family = "serif", event.text.fontface = 1,
    event.text.vjust = 0.5, event.text.lineheight = 1,
    event.above = TRUE, border.color = "white",
    border.linetype = 1, limits, ...)

Arguments

df

data for time periods.

events

data for events (optional).

label.col

the column name in df to use for labeling.

group.col

the column name in df to use for grouping.

start.col

the column name in df that specifies the start date.

end.col

the column name in df that specifies the end date.

text.size

the text size for labels in df.

text.color

the text color for labels in df.

text.position

the positioning of the text (i.e. left, right, or center).

text.alpha

the alpha level for labels.

text.angle

the angle for labels.

text.family

the font family for labels.

text.fontface

the font face for labels.

text.hjust

the horizontal adjustement for labels. The default will be set based upon the value of text.position.

text.vjust

the vertical adjustement for labels.

text.lineheight

the lineheight for labels.

num.label.steps

the number of steps to use for labeling events.

event.label.col

the column name in events to use for labeling.

event.col

the column name in events that specifies the date.

event.group.col

the column name in events to use for grouping.

event.spots

the number of rows to use for events. Note that each group in df is equal to one, so event.spots = 2 would be twice as high as one group row from df.

event.label

the label to use on the x-axis for events.

event.label.method

the labeling method. For method = 1 labels are printed horizontally; for method = 2 labels are printed at 45 degree angles.

event.line

whether to draw a vertical line for each event.

event.text.color

the text color of event labels.

event.text.size

the text size for event event labels.

event.text.alpha

the alpha level for event labels.

event.text.angle

the angle for event labels.

event.text.family

the font family for event labels.

event.text.fontface

the font face for event labels.

event.text.vjust

the vertical adjustement for event labels.

event.text.lineheight

the lineheight for event labels.

event.above

whether events should be plotted above (TRUE) or below (FALSE) time bars.

border.color

the color of the border around each box.

border.linetype

the linetype of the border around each box.

limits

the limits of the y-axis.

...

currently unused.

Examples

1
2
3
data(ww2)
timeline(ww2, ww2.events)
timeline(ww2, ww2.events, event.spots=2, event.label='', event.above=FALSE)

jbryer/timeline documentation built on May 18, 2019, 7:03 p.m.