[R] Incomplete x-axis in barplots

Marc Schwartz marc_schwartz at comcast.net
Wed Aug 6 18:35:48 CEST 2008


on 08/06/2008 10:42 AM Hanna Granroth wrote:
> Hi everyone,
> 
> This is a graphics question, concerning presentation rather than
> actually producing figures.
> After much fiddling I've managed to create bar plots showing error
> bars. I've put in an x-axis, which goes along all the bars, but
> doesn't appear between the y-axis and the first bar. I've searched all
> the resources I have access to but can't find anything addressing this
> issue. Does anyone know how to make the x-axis stretch all the way
> from the y-axis to the end of the right-most bar? It would make my
> picture beautifully complete!
> This is R 2.7.0 running on Windows XP.
> 
> Thanks very much,
> Hanna

Try this:

   barplot(1:10)
   box(bty = "l")

See ?box and ?par for 'bty'.

I don't use error bars on barplots any longer (my audience has changed), 
but you might want to look at the barplot2() function in the CRAN 
'gplots' package relative to adding these easily.

An example of use:

http://addictedtor.free.fr/graphiques/graphcode.php?graph=54

HTH,

Marc Schwartz



More information about the R-help mailing list