[R] Gantt chart - more than one colour on a line

Jim Lemon jim at bitwrit.com.au
Wed May 12 09:33:55 CEST 2010


On 05/12/2010 01:52 AM, D Holl wrote:
> Dear all
>
> I would like to plot a Gantt chart type plot, but with more than one
> colour on a line. The gantt.chart function will allow me to add more
> than one bar on a line, but it is in the same colour as the first bar
> on that line. For example (using the code helpful provided in the R
> graphics gallery)
>
> require(plotrix)
>
> Ymd.format<- "%Y/%m/%d"
>
> Ymd<- function(x){ as.POSIXct(strptime(x, format=Ymd.format))}
> gantt.info<- list(
>    labels     =c("First task","Second task","Third task","Fourth
> task","Fifth task","First task"),
>    starts     =Ymd(c("2004/01/01","2004/02/02","2004/03/03","2004/05/05","2004/09/09",
> "2004/09/01")),
>    ends       =Ymd(c("2004/03/03","2004/05/05","2004/05/05","2004/08/08","2004/12/12",
> "2004/09/10")),
>    priorities =c(1,2,3,4,5,5))
>
> gantt.chart(gantt.info,main="Calendar date Gantt chart")
>
> Both bars in the first line are red=priority level 1, rather than one
> red (level 1) and one purple (level 5)
>
> Am I missing some simple option in the gantt.chart function, or do I
> have to program the chart another way?
>
Hi DD,
I received a proposed change to gantt.chart a few days ago that enables 
just this capability. At the moment we are working out the best way to 
do this, and this feature will be in the next version (2.9-3) of plotrix.

Jim



More information about the R-help mailing list