Skip to content
Prev 248981 / 398506 Next

barplot with varaible-width bars

Bill Pikounis provided a clever and elegant solution:  in the program barplot.default, replace the statement

     width <- rep(width, NR)

that occours around line 51 ( NR = nrow(height) )  with the statement   width <- width.  I renamed the program

     barplotX.fn

and attached it to this email.  The attachment also includes a function called   mulbarX.fn  that mimics the
behavior of the original SPlus function    mulbar.  The call

mulbarX.fn(yy[,2*1:5],yy[,2*1:5-1],xlab="Baseline Category",ylab="Incidence",main="Main Title",sub="Low Volume",legendtxt=c("P","F"),ylim=c(0,0.15),
+ categlabs=c("Stratum 1","Stratum 2","Stratum 3","Stratum 4","Stratum 5"),legendinset=0.1,labcex=1.2)

produces a result that is very close to what the SPlus function produces.  This approach uses only basic R
graphics.  I imagine that it could be extended/incorporated into lattice or ggplot2 graphics.

Larry Gould