Learn R Programming

plotrix (version 2.5-2)

gantt.chart: Display a Gantt chart

Description

Displays a Gantt chart with priority coloring

Usage

gantt.chart(x=NULL,format="%Y/%m/%d",xlim=NULL,taskcolors=NULL,
  priority.legend=FALSE,vgridpos=NULL,vgridlab=NULL,vgrid.format="%Y/%m/%d",
  half.height=0.25,hgrid=FALSE,main="",xlab="",cylindrical=FALSE)

Arguments

x
a list of task labels, start/end times and task priorities as returned by get.gantt.info. If this is not present, get.gantt.info will be called.
format
the format to be used in entering dates/times (see strptime).
xlim
the horizontal limits of the plot.
taskcolors
a vector of colors used to illustrate task priority.
priority.legend
Whether to display a priority color legend.
vgridpos
optional positions of the vertical grid lines.
vgridlab
optional labels for the vertical grid lines.
vgrid.format
format for the vertical grid labels.
half.height
the proportion of the spacing between task bars that will be filled by the bar on each side - 0.5 will leave no space.
hgrid
logical - whether to display grid lines between the bars.
main
the title of the plot - note that this is actually displayed using mtext.
xlab
horizontal axis label - usually suppressed.
cylindrical
Whether to give the bars a cylindrical appearance.

Value

  • The list used to create the chart - see get.gantt.info for details. This can be saved and reused rather than manually entering the information each time the chart is displayed.

encoding

latin1

Details

If task priority colors are not wanted, set taskcolors to a single value to suppress the coloring. If this is not done, rainbow will be called to generate a different color for each task. There can now be more than one time interval for each task. If there is, more than one bar will be displayed for each "task", which may not be a task at all, but intervals of some attribute for each entity.

See Also

get.gantt.info

Examples

Run this code
Ymd.format<-"%Y/%m/%d"
 gantt.info<-list(labels=
  c("First task","Second task","Third task","Fourth task","Fifth task"),
  starts=
  as.POSIXct(strptime(
  c("2004/01/01","2004/02/02","2004/03/03","2004/05/05","2004/09/09"),
  format=Ymd.format)),
  ends=
  as.POSIXct(strptime(
  c("2004/03/03","2004/05/05","2004/05/05","2004/08/08","2004/12/12"),
  format=Ymd.format)),
  priorities=c(1,2,3,4,5))
 vgridpos<-as.POSIXct(strptime(c("2004/01/01","2004/02/01","2004/03/01",
  "2004/04/01","2004/05/01","2004/06/01","2004/07/01","2004/08/01",
  "2004/09/01","2004/10/01","2004/11/01","2004/12/01"),format=Ymd.format))
 vgridlab<-
  c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
 gantt.chart(gantt.info,main="Calendar date Gantt chart (2004)",
  priority.legend=TRUE,vgridpos=vgridpos,vgridlab=vgridlab,hgrid=TRUE)

Run the code above in your browser using DataLab