Description Usage Arguments Details Value Author(s) Examples
Creates a Gantt chart with horizontal or vertical lines
1 2 3 4 5 6 7 8 | gg_gantt_chart(data, var, var_levels = NULL, time, status = NULL,
group = NULL, group_levels = NULL, facet_r = NULL, facet_c = NULL,
facet_r_levels = NULL, facet_c_levels = NULL, facet_scale = "free",
facet_space = "free", x_lab = NULL, y_lab = NULL, group_lab = group,
title = NULL, label_align = "left", label_angle = NULL, grids = "on",
bw_theme = TRUE, horizontal = TRUE, point_shape_map = if (horizontal) {
list(start = 15, end = 16, ongoing = 45) } else { list(start = 15, end
= 16, ongoing = 45) }, point_size = 3, point_legend = FALSE)
|
data |
Data frame: default dataset to use for plot |
var |
Character: name of a |
var_levels |
Character vector: levels of |
time |
Character: name of a |
status |
Character: name of a |
group |
Character: name of a |
group_levels |
Vector/List: a named vector/list that specifies the
levels and labels of |
facet_r |
Character: name of a |
facet_c |
Character: name of a |
facet_r_levels |
Vector/List: a named vector/list that specifies the
levels and labels of |
facet_c_levels |
Vector/List: a named vector/list that specifies the
levels and labels of |
facet_scale |
Character: Are scales shared across all facets. Refer to
the 'scale' argument in |
facet_space |
Character: Refer to the 'space' argument in
|
x_lab |
Character: x-axis label |
y_lab |
Character: y-axis label |
group_lab |
Character: group variable label |
title |
Character: barplot title |
label_align |
Character: alignment of the event/project labels. If 'left' (default), labels will be left-aligned; if 'center', labels will be center-aligned; if 'right', labels will be right-aligned |
label_angle |
Character: the orientation angle (in [0, 360]) of the event/project labels on the axis. By default, the label will be perpendicular to the axis |
grids |
Character: control the grids. If 'on' (default), grids will be drawn; if 'x', only grids on x-axis will be drawn; if 'y', only grids on y-axis will be drawn; if 'off', no grids will be drawn |
bw_theme |
Logical: If |
horizontal |
Logical: If |
point_shape_map |
List/Character vector/Numeric vector: specify points
shape mapping to |
point_size |
Numeric: size of the points. Must be positive value |
point_legend |
Logical: If |
bar_label_angle |
Numeric: the orientation angle (in [0, 360]) of the bar labels on the axis. By default, the label will be perpendicular to the axis |
This function relies on ggplot2 package to
create a Gantt chart with vertical or horizontal lines. The function supports
panel plot layout. Points can be added at the start and end of the lines
and the point shape specification is supported through status
and
point_shape_map
arguments together. Refer to the description of the
two arguments for more details
An object of class ggplot. Can be directly sent to plot with
print
Feiyang Niu (Feiyang.Niu@gilead.com)
1 2 3 4 5 6 7 8 9 10 11 12 | test_df <- data.frame(
project = rep(paste('Project', 1:10), each = 2),
time = c(rbind(sample(1:5, 10, replace = TRUE),
sample(6:8, 10, replace = TRUE))),
status = factor(c(rbind(rep('start', 10),
c(rep('end', 5), rep('ongoing', 5)))),
levels = c('start', 'ongoing', 'end'))
)
gg_gantt_chart(test_df, var = 'project', time = 'time',
status = 'status', y_lab = '', grids = 'y')
gg_gantt_chart(test_df, var = 'project', time = 'time',
status = 'status', point_legend = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.