Hi Larry, If I understand correctly, your barplot() call dispatches to the method function barplot.default() to do the work. Looking at the definition of that function and your specific call, it seems that around line 51 of barplot.default(), the value of the width argument is truncated:
width <- rep(width, length.out = NR) where NR <- nrow(height) is defined a bit earlier around line 44. So in the execution width takes on the value [1] 417 153 which seems to explain the same width pieces across pairs. Just quick and dirty I copied the function barplot.default in the workspace to an editor, renamed it as mod.barplot.default() and then commented out line 51 and added the line there: width <- width which seems at though it could actually be left out as long as beside=TRUE is kept in the call. Then I created mod.barplot.default() as a working function, and this call mod.barplot.default(yy[,2*1:5], las=1, width=yy[,(2*1:5)-1], space=c(.1,.5) ,beside=TRUE) looks like it might provide what you wanted. Hope that helps. Bill ------------------------- Bill Pikounis http://billpikounis.net/ On Tue, Jan 25, 2011 at 10:47, Gould, A. Lawrence <larry_go...@merck.com> wrote: > I would like to produce a bar plot with varying-width bars. Here is an > example to illustrate: > > ww <- c(417,153,0.0216,0.0065,556,256,0.0162,0.0117, > + 726,379,0.0358,0.0501,786,502,0.0496,0.0837, > + 892,591,0.0785,0.0795) > yy<-t(t(array(ww,c(2,10)))) > > barplot(yy[,2*1:5],las=1,space=c(.1,.5),beside=T) > > produces a barplot of 5 pairs of bars that are of equal width > > barplot(yy[,2*1:5],las=1,width=c(yy[,(2*1:5)-1]),space=c(.1,.5),beside=T) > > makes the bars in each pair of unequal width, but the two widths do not vary > from pair to pair > > I would like the width of each bar to be proportional to its corresponding > value in the width statement of this last call of barplot, like what I think > could be done with the mulbar function of SPlus. Can I do this with barplot > itself, or is this something for which lattice or ggplot 2 is needed? And, > if so, what would typical code look like? > > Thanks for your help. > > Larry Gould > > > Notice: This e-mail message, together with any attachme...{{dropped:14}} > > ______________________________________________ > R-help@r-project.org 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. > ______________________________________________ R-help@r-project.org 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.