[R] Gantt chart but slightly different

Jim Lemon jim at bitwrit.com.au
Sat May 9 13:56:05 CEST 2009


Beata Czyz wrote:
> Hello,
> I am new to this list and rather new to graphics with R.
> I would like to make a chart like Gantt chart, something like that:
> ...
> but I would like to fill the different blocks of tasks with different
> pattern i.e. first blocks of Male 1 and Male 2 with pattern 1, second
> blocks of Male 1 and Male 2 with pattern 2 etc.
> Any idea?

Hi Beata,
This could be done by replacing the "taskcolors" argument in the 
"gantt.chart" function with an "angle" argument and passing that 
argument to the "rect" function that draws the bars. You could then get 
hatching of different directions instead of colors. Like this:

gantt.chart<-function(x=NULL,format="%Y/%m/%d",xlim=NULL,
 angle=c(45,45,90,90,135,135),
 priority.legend=FALSE,vgridpos=NULL,vgridlab=NULL,vgrid.format="%Y/%m/%d",
 half.height=0.25,hgrid=FALSE,main="",xlab="",cylindrical=FALSE) {

(a great chunk of the gantt.chart function)

 rect(x$starts[x$labels==tasks[i]],topdown[i]-half.height,
   x$ends[x$labels==tasks[i]],topdown[i]+half.height,
   angle=angle[i],border=FALSE)


(the rest of the gantt.chart function)

Jim




More information about the R-help mailing list