Skip to content

Suggestion: barplot function

3 messages · Robert Baer, Marc Schwartz, danielrenato at lycos.com

#
On 1/27/2017 8:30 AM, danielrenato at lycos.com wrote:
Marc may not speak for R Core, but he certainly has summarized what has 
been an apparent consensus attitude to barplot() and confidence bars in 
this community over the last decade.  Further, he is probably right 
about no changes after this many years.

I might mention that if you want a close cousin to barplot() that does 
what you want with base graphics (from the drawing mechanics point of 
view) see the barplot2() function in the gplots package. You provide 
your own bar lengths.  Regardless of their merits, barplots are a common 
graphing mechanism used by my scientific colleagues to convey their 
data, and I don't see that changing any time soon.  The one thing that 
is even less forgivable than dynamite plots is bars with no dispersion 
indication at all. Too bad barplot2() isn't the default.

  
    
#
Hi,

Since Robert has kindly raised the barplot2() function, in the interest of full disclosure, as the original author of that function, my prior comments may seem contradictory.

I originally wrote the barplot2() function back in 2002 (https://stat.ethz.ch/pipermail/r-devel/2002-September/025092.html <https://stat.ethz.ch/pipermail/r-devel/2002-September/025092.html>), based upon my usage patterns at the time. It included the ability to use log scaled axes (later added to base R's barplot()), binomial confidence intervals and some other features, building directly on the default barplot() function code in base R for compatibility.

It was an early attempt back then, to give back to the community based upon some requests at the time. Greg Warnes was subsequently kind enough to offer to include it in the gplots package on CRAN.

That being said, because of the issues that I raised in my prior reply, which also reflect my own evolution in thinking in the many years since, I have not used the barplot2() function nor modified/updated the code in any way in well over 10 years. In fact, in general, I find that my clients in the clinical domains that I work in, have also come to see less value in their use, in deference to other presentation formats and I rarely use them in my analyses. As I noted in my prior reply, where I see them still commonly used tends to be for tabulations/counts for things like monthly/quarterly clinical trial enrollment trends, etc.

In either case, Robert rightly raises the point that, despite the criticisms, they are still widely used as change can be slow to manifest. Thus, there are options to create such plots where desired, using barplot2(), the ggplot2 package and other functions in various CRAN packages. Or as I noted, if you don't want to install a package just for the sake of this one feature, it is easy to create them with a few function calls like segments() or arrows() over the default barplot.

Regards,

Marc

  
  
16 days later
#
Hi Marc and Robert, 

Thank you so much for the answer! 

I agree with both of you, specially with Robert "barplots are a common
graphing mechanism used by my scientific colleagues to convey their
data, and I don't see that changing any time soon... The one thing that
is even less forgivable ... is bars with no dispersion indication at
all." (what barplot() allows). 

Nowadays there are dozens of new papers everyday, and to make it
easier/faster to the readers, it is very common (in biological sciences)
authors show the data using bar-plots (that represent mean of treatments
and the standard deviation - and usually with letters representing if
the treatments are different, or not, using some statistical test). 

Maybe it is not a great way, but it is in an intuitive way largely used
in natural sciences that make it easier to the readers. And it is
accepted in most of the scientific journals, including Science, Nature,
PNAS, Frontiers... 

I agree with Marc that it is nice that R is flexible, so people can go
around even that it is not the default. However it is a difficult task
for most of the users (e.g.from biological sciences). 

Thank you Marc and Robert, 

Cheers, Daniel
On 2017-02-03 14:23, Robert Baer wrote: