[R] simple graphing question

Paul Johnson pauljohn32 at gmail.com
Tue Apr 8 22:09:40 CEST 2008

On Tue, Apr 8, 2008 at 2:18 PM, stephen sefick <ssefick at gmail.com> wrote:
> #copy and paste this into R
>  f <- (structure(list(TKN = c(0.103011025, 0.018633208, 0.104235702,
>  0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61)), .Names = c("TKN",
>  "RM"), class = "data.frame", row.names = 25:29))
>  plot(f$TKN~f$RM, type="b")
>  I would like to reverse the X-Axis.  How do I do this?

Hello, Stephen:

It appears you might be new in R, so let me point out a couple of
things.  First, this works:

f <- data.frame( TKN = c(0.103011025, 0.018633208,
0.104235702,0.074537363, 0.138286096), RM = c(215, 198, 148, 119, 61),
row.names = 25:29)

plot(TKN~RM, data=f, type="b", xlim=rev(range(f$RM)))

Note that I've created your data frame in a more usual way and I've
reversed the x axis in the plot by reversing the range of the X
variable. I've also used the data option to plot

Second, I had  reversed an axis before, but I quickly learned how by
typing the following command:

RSiteSearch("reverse axis")

That opened up the web browser and it listed many items, the second of
which was this:


thread, the title of which is "How to reverse the sequence of axis Y ? "

Generally, if you try RSiteSearch() and don't find what you need after
exploring a page or two of threads, then you can post here and ask
questions without people saying "go read the posting guide before
posting questions."

Good luck

Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

More information about the R-help mailing list