[R] invert y-axis in barplot

Marc Schwartz (via MN) mschwartz at mn.rr.com
Wed Nov 16 17:19:47 CET 2005


On Wed, 2005-11-16 at 16:46 +0000, JÃ¶rg Schlingemann wrote:
> Hi!
> 
>  
> 
> This is probably a very trivial question. Is there an easy way to invert the
> y-axis (low values on top) when using the function barplot()? 
> 
>  
> 
> Thanks,
> 
> Jrg

You mean something like this?:

  barplot(1:10, ylim = rev(c(0, 12)))

or, something like this?:

  barplot(1:10, yaxt = "n") 
  axis(2, labels = rev(seq(0, 10, 2)), at = seq(0, 10, 2))


Note the use of rev() in each case.

HTH,

Marc Schwartz




More information about the R-help mailing list