I am having a problem with a gantt chart since moving to R2.4.0. from 2.3.1 I made some adaptations to the code from http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=74 and successful produced a simple gantt chart. However when I upgraded to 2.4.0 it no longer works as desired. See http://ca.geocities.com/jrkrideau/R/gantproblem.pdf for the two charts. The charts were produced today using the same version of plotrix (installed on both versions of R today) System : Windows XP I am pretty new to R and especially to plotrix and I don't see what I am doing wrong. I have tried to play around with the Ymd.format with no luck Have I missed something in the upgrade notes? Can anyone suggest something? Thanks My code is: require(plotrix) Ymd.format <- "%Y/%m/%d" Ymd <- function(x){ as.POSIXct(strptime(x, format=Ymd.format))} gantt.info <- list( labels =c("Dickens", "Doyle", "Kipling", "Poe"), starts =Ymd(c("1824/01/01", "1850/01/01", "1865/01/01", "1815/11/01")), ends =Ymd(c("1901/01/01", "1922/01/01", "1935/01/01", "1867/01/01")), priorities =c(1,2,2,4)) gantt.chart(gantt.info,main="Writers", xlim=as.POSIXct(c("1810/01/01","1940/01/01"))) John Kane Kingston ON Canada
John Kane wrote:> I am having a problem with a gantt chart since > moving to R2.4.0. from 2.3.1 > > I made some adaptations to the code from > http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=74 > > and successful produced a simple gantt chart. However > when I upgraded to 2.4.0 it no longer works as > desired. See > http://ca.geocities.com/jrkrideau/R/gantproblem.pdf > for the two charts. The charts were produced today > using the same version of plotrix (installed on both > versions of R today) > > System : Windows XP > > I am pretty new to R and especially to plotrix and I > don't see what I am doing wrong. I have tried to play > around with the Ymd.format with no luck Have I > missed something in the upgrade notes? Can anyone > suggest something? Thanks >Hi John, I tried your code at home on a Linux system with R-2.3.1 and it seemed to work fine. Unfortunately, I can't try it on Windows until I get to work on Tuesday. I'll try to upgrade this box (I have been somewhat wary with all the things that seem to have gotten a bit bent) this weekend and try it again. Jim
apjaworski at mmm.com
2006-Nov-17 22:17 UTC
[R] Gantt chart problem after upgrade to R 2.4.0
This is interesting. I am on Win2000 running R version 2.4.0 Patched (2006-11-15 r39915) and plotrix 2.1.5. I get the plot that scaled a little differently that the 2.3.1 example but the dates look fine. I ran the original code posted by John cane with no changes (copy and paste). I used the windows device and did "Save As..." to save the PDF file. Here is the code: require(plotrix) Ymd.format <- "%Y/%m/%d" Ymd <- function(x){ as.POSIXct(strptime(x, format=Ymd.format))} gantt.info <- list( labels=c("Dickens", "Doyle", "Kipling", "Poe"), starts=Ymd(c("1824/01/01", "1850/01/01", "1865/01/01", "1815/11/01")), ends=Ymd(c("1901/01/01", "1922/01/01", "1935/01/01", "1867/01/01")), priorities =c(1,2,2,4)) gantt.chart(gantt.info,main="Writers", xlim=as.POSIXct(c("1810/01/01","1940/01/01"))) Here is the result: (See attached file: plot.pdf) Cheers, Andy __________________________________ Andy Jaworski 518-1-01 Process Laboratory 3M Corporate Research Laboratory ----- E-mail: apjaworski at mmm.com Tel: (651) 733-6092 Fax: (651) 736-3122 "No No" <nono.231 at gmail.c om> To Sent by: "John Kane" <jrkrideau at yahoo.ca> r-help-bounces at st cc at.math.ethz.ch R R-help <r-help at stat.math.ethz.ch> Subject Re: [R] Gantt chart problem after 11/17/2006 03:35 upgrade to R 2.4.0 PM I am on ubuntu linux with R 2.4.0 compiled and I get the same picture as with yours with R 2.4.0. ______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -------------- next part -------------- A non-text attachment was scrubbed... Name: plot.pdf Type: application/pdf Size: 4127 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20061117/125ef38e/attachment.pdf
John Kane wrote:> I am having a problem with a gantt chart since > moving to R2.4.0. from 2.3.1 > ...Okay, I think I have fixed the problem. I don't yet know why it worked on Windows and not Linux, but this should work on both. I have added another argument to the gantt.chart function and it seems to overcome the problem. Haven't tested it extensively, so I would appreciate any information about bugs that have sprung from the ichor of the one I squashed. There will be another version of plotrix shortly and this will be in it. Jim Watch out for the line breaks that have crept into the code. gantt.chart<-function(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="",ylab="") { oldpar<-par(no.readonly=TRUE) if(is.null(x)) x<-get.gantt.info(format=format) ntasks<-length(x$labels) plot.new() charheight<-strheight("M",units="inches") maxwidth<-max(strwidth(x$labels,units="inches"))*1.5 if(is.null(xlim)) xlim=range(c(x$starts,x$ends)) npriorities<-max(x$priorities) if(is.null(taskcolors)) taskcolors<-color.gradient(c(255,0),c(0,0),c(0,255),npriorities) else { if(length(taskcolors) < npriorities) taskcolors<-rep(taskcolors,length.out=npriorities) } bottom.margin<-ifelse(priority.legend,0.5,0) par(mai=c(bottom.margin,maxwidth,charheight*5,0.1)) par(omi=c(0.1,0.1,0.1,0.1),xaxs="i",yaxs="i") plot(x$starts,1:ntasks,xlim=xlim,ylim=c(0.5,ntasks+0.5), main="",xlab="",ylab=ylab,axes=FALSE,type="n") box() if(nchar(main)) mtext(main,3,2) if(is.null(vgridpos)) tickpos<-axis.POSIXct(3,xlim,format=vgrid.format) else tickpos<-vgridpos # if no tick labels, use the grid positions if there if(is.null(vgridlab) && !is.null(vgridpos)) vgridlab<-format.POSIXct(vgridpos,vgrid.format) # if vgridpos wasn't specified, use default axis ticks if(is.null(vgridlab)) axis.POSIXct(3,xlim,format=vgrid.format) else axis(3,at=tickpos,labels=vgridlab) topdown<-seq(ntasks,1) axis(2,at=topdown,labels=x$labels,las=2) abline(v=tickpos,col="darkgray",lty=3) for(i in 1:ntasks) { rect(x$starts[i],topdown[i]-half.height, x$ends[i],topdown[i]+half.height, col=taskcolors[x$priorities[i]], border=FALSE) } if(hgrid) abline(h=(topdown[1:(ntasks-1)]+topdown[2:ntasks])/2,col="darkgray",lty=3) if(priority.legend) { par(xpd=TRUE) plim<-par("usr") gradient.rect(plim[1],0,plim[1]+(plim[2]-plim[1])/4,0.3,col=taskcolors) text(plim[1],0.2,"Priorities ",adj=c(1,0.5)) text(c(plim[1],plim[1]+(plim[2]-plim[1])/4),c(0.4,0.4),c("High","Low")) } par(oldpar) invisible(x) }
--- apjaworski at mmm.com wrote:> This is interesting. I am on Win2000 running R > version 2.4.0 Patched > (2006-11-15 r39915) and plotrix 2.1.5. I get the > plot that scaled a little > differently that the 2.3.1 example but the dates > look fine.My fault there. I simply copied the metafile and sized it in a WP before exporting to PDF.> I ran the original code posted by John cane with nochanges> (copy and paste). I used > the windows device and did "Save As..." to save the > PDF file.I agree. It seems to work perfectly with R-2.4.0 Patched. I had not realized that there was a Patch version out already but as soon, as I upgraded, the gantt looked fine. However one serous complaint : Kane not cane!!!! Thanks a lot. This saves a lot of time and trouble.> Here is the code: > > require(plotrix) > Ymd.format <- "%Y/%m/%d" > Ymd <- function(x){ as.POSIXct(strptime(x, > format=Ymd.format))} > gantt.info <- list( > labels=c("Dickens", "Doyle", "Kipling", > "Poe"), > starts=Ymd(c("1824/01/01", "1850/01/01", > "1865/01/01", "1815/11/01")), > ends=Ymd(c("1901/01/01", "1922/01/01", > "1935/01/01", "1867/01/01")), > priorities =c(1,2,2,4)) > gantt.chart(gantt.info,main="Writers", > xlim=as.POSIXct(c("1810/01/01","1940/01/01"))) > > Here is the result: > > (See attached file: plot.pdf) > > Cheers, > > Andy > > __________________________________ > Andy Jaworski > 518-1-01 > Process Laboratory > 3M Corporate Research Laboratory > ----- > E-mail: apjaworski at mmm.com > Tel: (651) 733-6092 > Fax: (651) 736-3122
--- No No <nono.231 at gmail.com> wrote:> I am on ubuntu linux with R 2.4.0 compiled and I get > the same picture > as with yours with R 2.4.0.Thanks. From another reply it looks like this is a 2.4.0 problem that is solved in 2.4.0-patched and not a Windows vs Linux problem. I upgraded to the patch this morning and the plot looks as lovely as before. Well lovely to me anyway :)