[R] Simple plot() question

michael watson (IAH-C) michael.watson at bbsrc.ac.uk
Tue Nov 16 15:45:24 CET 2004


Hi

First a simple question to do with plot().  How do I change the x-axis
labels on a plot?

For example, I am plotting each row of a matrix, and I want each row to
be a line on my graph.  Simple really.  Eg:

plot(sg[1,], type="l")

When I do this, the x-axis is labelled 1:38, as I have 38 columns in my
matrix.  When I do:

plot(sg[1,order(sg[1,])], type="l")

Ideally I would like the x-axis labels to reflect the new order of the
columns, but they're still numbered 1:38... I've read the plot() docs
and the par() docs and can't figure it out - I know I'm missing
something obvious, but what?

Cheers

Mick

Michael Watson
Head of Informatics
Institute for Animal Health,
Compton Laboratory,
Compton,
Newbury,
Berkshire RG20 7NN
UK

Phone : +44 (0)1635 578411 ext. 2535
Mobile: +44 (0)7990 827831
E-mail: michael.watson at bbsrc.ac.uk




More information about the R-help mailing list