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.
Jason
What about making x a factor? Sarah On Mon, Jul 14, 2008 at 11:00 AM, Jason Liao <jg_liao at yahoo.com> 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. > > Jason-- Sarah Goslee http://www.functionaldiversity.org
Try: library(lattice) xyplot(y ~ factor(x)) or plot(1:length(x), y, xaxt='n') axis(1, at=1:length(x), labels=x) On Mon, Jul 14, 2008 at 12:00 PM, Jason Liao <jg_liao at yahoo.com> 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. > > 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
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
How about:
plot.default(factor(x), y, xaxt='n', xlab='x')
axis(1, at=factor(x), labels=x)
----- Original Message -----
From: "Jason Liao" <jg_liao at yahoo.com>
To: <r-help at r-project.org>
Sent: Monday, July 14, 2008 10:00 AM
Subject: [R] A question about using function plot
> 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.
>
> 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.
>
Reasonably Related Threads
- how to find the location of the first TRUE of a logical vector
- setting the steps for x axis labels on plot
- fastest way to compute the squared Euclidean distance between two vectors in R
- when can we expect Prof Tierney's compiled R?
- extremely slow recursion in R?