[R] A question about using function plot

Chuck Cleland ccleland at optonline.net
Mon Jul 14 18:29:39 CEST 2008


On 7/14/2008 11:00 AM, Jason Liao wrote:
> Hello, everyone! I have spent two hours to get what I wanted in a simple situation and have not been successful. The set up is extremely simple
> 
> x = c(1,2,4,8)
> y = c(1,2,3,4)
> plot(x, y)
> 
> What I need, however, is for the 4 points of 1,2,4,8 to be spaced evenly, not by their numerical scale. Also, there should not be any other values such as 5,6,7 marked on the axis.
> 
> So I tried the following
> 
> 
> x = c("1","2","4","8")
> y = c(1,2,3,4)
> plot(x, y)
> 
> No help at all.
> 
> Anyone can point me to the right way? Thank you very much.

x = c("1","2","4","8")
y = c(1,2,3,4)
plot(seq_along(x), y, xaxt="n", xlab="x")
axis(side=1, at=seq_along(x), labels=x)

> Jason
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list