[R] plot the y-axis upside down

Owen, Jason wowen at richmond.edu
Fri Jun 17 22:13:04 CEST 2011


That's fantastic!  Thanks.


> -----Original Message-----
> From: Marc Schwartz [mailto:marc_schwartz at me.com]
> Sent: Friday, June 17, 2011 3:47 PM
> To: Owen, Jason
> Cc: 'r-help at r-project.org'
> Subject: Re: [R] plot the y-axis upside down
>
> On Jun 17, 2011, at 2:31 PM, Owen, Jason wrote:
>
> > Hello,
> >
> > I need to create a scatterplot where the y-axis is upside down.  If I
> have non-negative bivariate data in objects "x" and "y," then the
> operation
> >
> > plot(x, -y)
> >
> > gives me the figure I want -- a mirror image of plot(x, y) -- except
> that the y-values (coordinates) are negative, which I don't want.  Is
> there a simple way to do this?
> >
> > Jason
>
>
> This is where the 'ylim' argument to plot is helpful, along with ?rev
> and ?range:
>
>   x <- 1:10
>   y <- 1:10
>   plot(x, y)
>
> versus:
>
>   plot(x, y, ylim = rev(range(y)))
>
> HTH,
>
> Marc Schwartz



More information about the R-help mailing list