[R] Simple plot() question

James W. MacDonald jmacdon at med.umich.edu
Tue Nov 16 16:01:59 CET 2004


michael watson (IAH-C) wrote:
> 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?

You want to add xaxt="n" so the x-axis labels are not printed. Then add 
your new labels using axis(1, at=1:38, labels=<some vector of label names>)

HTH,

Jim


> 
> 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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
James W. MacDonald
Affymetrix and cDNA Microarray Core
University of Michigan Cancer Center
1500 E. Medical Center Drive
7410 CCGC
Ann Arbor MI 48109




More information about the R-help mailing list